Im developing an application and so far have been facing weird issues that I don’t even want my enemy to face.
Source code
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gdk, Gtk
class StatusLabel:
def __init__(self, text, show_progress):
self.label = Gtk.Label(
name="promptframe-statuslabel",
label=text,
valign=1)
use_markup=True, #Comment this line
wrap=True) #Comment this line
self.spin = Gtk.Spinner()
if show_progress:
self.spin.start()
self.grid = Gtk.Grid(column_spacing=2)
self.grid.attach(self.label, 0, 0, 1, 1)
self.grid.attach(self.spin, 1, 0, 1, 1)
def set_text(self, label):
self.label.set_text(label)
def set_name(self, name):
self.label.set_name(name)
def start_spin(self):
self.spin.start()
def stop_spin(self):
self.spin.stop()
def get_widget(self):
return self.grid
box = Gtk.Box(orientation=1, valign=1)
ent = Gtk.Entry(text=">>> ", valign=1)
box.pack_start(ent, 1, 1, 1)
def add_status(wid, event):
keyname = Gdk.keyval_name(event.keyval)
if keyname != "Control_R":
return
text = ent.get_text()
text = text + text[::-1] + text.upper() + text.lower() #Some long text
st = StatusLabel(text=text, show_progress=False)
box.pack_end(st.get_widget(), 1, 1, 1)
box.show_all()
ent.connect("key-press-event", add_status)
win = Gtk.Window()
win.connect("destroy", Gtk.main_quit)
win.add(box)
win.show_all()
Gtk.main()
The problem is why does the wrap mode add some extra space below it. I produced a minimal working example by adding an entry inside a box. Type some text inside it and press control_r. Now some text will be displayed but you can see that there is some extra space added at last. You can’t even resize the window to delete that space.
Now just comment the mentioned lines in source code and some text, viola! There is no additional space. Beautiful.
Now someone please help me why is it happening like this.
And another weird issue I faced is (this example doesn’t reproduce it), sometimes, the cursor disappears inside my application window. Or it simply freezes. Then GNOME shows me that my application isn’t responding and I kill it.
Any help appreciated