PEP E721
This commit is contained in:
parent
2f4f28af1c
commit
d5e55f8aad
@ -9,17 +9,14 @@ from gi.repository import Gdk, GdkPixbuf, Gio, Gtk, Pango
|
||||
|
||||
|
||||
def format_label(widget, lines=2):
|
||||
if type(widget) == Gtk.Label:
|
||||
return widget
|
||||
if type(widget) in (Gtk.Container, Gtk.Bin, Gtk.Button, Gtk.Alignment, Gtk.Box):
|
||||
if isinstance(widget, Gtk.Label):
|
||||
widget.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
widget.set_line_wrap(True)
|
||||
widget.set_ellipsize(Pango.EllipsizeMode.END)
|
||||
widget.set_lines(lines)
|
||||
elif isinstance(widget, (Gtk.Container, Gtk.Bin, Gtk.Button, Gtk.Alignment, Gtk.Box)):
|
||||
for _ in widget.get_children():
|
||||
lbl = format_label(_)
|
||||
if lbl is not None:
|
||||
lbl.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
|
||||
lbl.set_line_wrap(True)
|
||||
lbl.set_ellipsize(True)
|
||||
lbl.set_ellipsize(Pango.EllipsizeMode.END)
|
||||
lbl.set_lines(lines)
|
||||
format_label(_, lines)
|
||||
|
||||
|
||||
class KlippyGtk:
|
||||
@ -187,12 +184,12 @@ class KlippyGtk:
|
||||
widget.set_sensitive(False)
|
||||
widget.set_always_show_image(False)
|
||||
box.get_children()[0].hide()
|
||||
if type(box.get_children()[1]) == Gtk.Spinner:
|
||||
if isinstance(box.get_children()[1], Gtk.Spinner):
|
||||
box.get_children()[1].start()
|
||||
box.get_children()[1].show()
|
||||
else:
|
||||
box.get_children()[0].show()
|
||||
if type(box.get_children()[1]) == Gtk.Spinner:
|
||||
if isinstance(box.get_children()[1], Gtk.Spinner):
|
||||
box.get_children()[1].stop()
|
||||
box.get_children()[1].hide()
|
||||
widget.set_always_show_image(True)
|
||||
|
@ -788,7 +788,7 @@ class KlipperScreen(Gtk.Window):
|
||||
|
||||
def _send_action(self, widget, method, params):
|
||||
logging.info(f"{method}: {params}")
|
||||
if type(widget) == Gtk.Button:
|
||||
if isinstance(widget, Gtk.Button):
|
||||
self.gtk.Button_busy(widget, True)
|
||||
self._ws.send_method(method, params, self.enable_widget, widget)
|
||||
else:
|
||||
@ -796,7 +796,7 @@ class KlipperScreen(Gtk.Window):
|
||||
|
||||
def enable_widget(self, *args):
|
||||
for x in args:
|
||||
if type(x) == Gtk.Button:
|
||||
if isinstance(x, Gtk.Button):
|
||||
GLib.timeout_add(150, self.gtk.Button_busy, x, False)
|
||||
|
||||
def printer_initializing(self, msg, remove=False):
|
||||
|
Loading…
x
Reference in New Issue
Block a user