Native gui first steps: storage, box and companies are editable

This commit is contained in:
thooge committed 2026-10-21 17:16:55 +02:00
1 parent 1eea4058bf
commit 06a9834688
47 files changed
+3119 -883

No files matched your search

+49
View File
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: WTFPL
from gi.repository import Gtk
def init_named_controls(window, builder):
@@ -74,3 +76,50 @@ def get_text_contents(textview):
"""
buf = textview.get_buffer()
return buf.get_text(buf.get_start_iter(), buf.get_end_iter(), True)
class TouchPopup():
"""
A pop-up window that can be closed again with another click.
The pop-up features a title in bold, as well as a list of labels and values.
"""
#TODO finish converting to GTK3
def __init__(self, parent, title, data, width=None):
self.window = win = gtk.Window(Gtk.WindowType.POPUP)
win.set_position(Gtk.WindowPosition.MOUSE)
win.set_transient_for(parent)
win.set_modal(True)
if width:
win.set_size_request(width, -1)
#win.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#feffd0"))
win.override_background_color(
Gtk.StateFlags.NORMAL,
Gdk.RGBA(1.0, 1.0, 0.816, 1.0) # #feffd0
)
frame = Gtk.Frame()
frame.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
frame.set_border_width(2)
win.add(frame)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
frame.add(vbox)
# Title
label = Gtk.Label("<b>" + title + "</b>")
label.set_use_markup(True)
label.set_alignment(0.0, 0.5)
vbox.pack_start(label)
# Data
sg = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
for d in data:
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
vbox.pack_start(hbox)
label = Gtk.Label(d[0])
label.set_alignment(0.0, 0.5)
hbox.pack_start(label, False, False, 4)
sg.add_widget(label)
label = Gtk.Label(d[1])
label.set_alignment(0.0, 0.5)
hbox.pack_start(label)
win.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
win.connect('button-press-event', self.callback)
win.show_all()
def callback(self, window, event):
window.destroy()