Source

vasm / src / vasm / ui / gtk2 / support / widgets.py

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
#!/usr/bin/env python

#    This file is part of VASM.
#
#    VASM is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License v3 as published by
#    the Free Software Foundation.
#
#    VASM is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with VASM.  If not, see <http://www.gnu.org/licenses/>.

import os
import imp
import gtk
import pango
import time
from threading import Event
import datetime
from vasm.backend.utils import _, get_popen, MonitoredExternalGui
import logging
logger = logging.getLogger('vasm')

__author__ = "Moises Henriquez"
__author_email__ = "moc.liamg@xnl.E0M"[::-1]
vlbluecolor = gtk.gdk.color_parse("#003063")
vllightbluecolor = gtk.gdk.color_parse("#6d87a3")
modulesdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
horizontal = gtk.HBox
vertical = gtk.VBox

    


class OptionsBox(gtk.HBox):
    """ Box used to present a group of options to the user.
    Arguments:
        title   Title for the options.
        orientation     Orientation method can be horizontal or vertical.
        options     Iterrable collection of options to be presented.
        """
    def __init__(self, label=None, orientation=horizontal, options = []):
        gtk.HBox.__init__(self)
        self._body = orientation()
        self._options = []
        self.observers = []
        if label is not None:
            self.label = gtk.Label()
            self.label.set_use_markup(True)
            self.label.set_markup(label)
            self.label.set_property('xalign', 0.0)
            self._body.pack_start(self.label, False, False, 4)
        # Add the options
        for item in options:
            choice, data = item
            grp = self._get_rb_group()
            wid = gtk.RadioButton(grp, choice)
            wid.user_data = data
            wid.connect('toggled', self.radio_toggle)
            self._options.append(wid)
            self._body.pack_start(wid, False, False, 2)
        self.pack_start(self._body, True, True, 0)
    
    def _get_rb_group(self):
        if len(self._options) > 0:
            return self._options[0]
        return None
    
    def add_observer(self, method):
        return self.observers.append(method)
    
    def notify(self, data):
        for f in self.observers:
            f(data)
    def radio_toggle(self, radio):
        if radio.get_active():
            return self.notify(radio)

class HOptionsBox(OptionsBox):
    def __init__(self, label=None, options=[]):
        OptionsBox.__init__(self, label, options, orientation=horizontal)
    
class VOptionsBox(OptionsBox):
    def __init__(self, label=None, options=[]):
        OptionsBox.__init__(self, label, options, orientation=vertical)

class VasmSubModule(gtk.VBox):
    """ Submodule widget to be used as a sub-category display """
    def __init__(self, parent=None, parent_category="", module_title="", icon=None):
        self._parent = parent
        self.icon = icon
        self._parent_category = parent_category
        gtk.VBox.__init__(self)
        self.members = []
        self.title = module_title
        # we want an iconview to display the options.
        self.holder = SettingsHolder(module_title,icon, self._parent)
        self.pack_start(self.holder ,True, True, 0)

        # Add a 'back' button
        self.action_area = gtk.HBox()
        closebtn = gtk.Button(stock=gtk.STOCK_GO_BACK)
        closebtn.connect('clicked', self.close_module)
        self.action_area.pack_end(closebtn, False, False, 4)
        # Leave the action area unpacked because the main UI will put it in a different spot.
        # self.pack_end(self.action_area, False, True, 4)
        
        # Add a separator
        sep = gtk.HSeparator()
        self.pack_end(sep, False, True, 0)
        # add the modules here
        self.discover_modules()
    
    def add_option(self, module):
        """ Add module launcher to the appriopriate view """
        # we only have one iconview, so just create the entry there
        self.holder.add_launcher(
            label = module.VASM_LABEL,
            icon = module.VASM_ICON,
            actuator = self.run_module(module)
        )

    def run_module(self, module):
        #self._active_module_ = module.VASM_LABEL
        return module.__run__
    
    def discover_modules(self):
        """ Discover the modules pluggable into vasm """
        modulesdir = os.path.join(os.path.dirname(
            os.path.dirname(__file__)), 'modules')
        
        #modulesdir = os.path.join(os.getcwd(), "modules")
        for fname in sorted(os.listdir(modulesdir)):
            viewer = None
            if fname.endswith(".py") and fname !="__init__.py":
                pyname = fname[:-3]
                vasm_mod = self.load_module(pyname, fname, [modulesdir])
                if self.test_vasm_module(vasm_mod):
                    if vasm_mod.__vasm_test__():
                        # Module has paseed the test.  Add to the views
                        # Check if this is the category where the module belongs
                        parent, child = self.get_parent_child_tuple(vasm_mod)
                        if parent == self._parent_category and child == self.title:
                            logger.debug('Adding subcategory %s/%s'% (
                                self._parent_category, self.title))
                            self.add_option(vasm_mod)

    def load_module(self, name, fname, path=[modulesdir]):
        """ return a named module found in the given path"""
        mod = imp.find_module(name, path)
        ret = imp.load_module(name, mod[0], fname, mod[2])
        return ret
    
    def get_parent_child_tuple(self, module):
        """ split the parent category from subcategory """
        parent, sub = module.VASM_CATEGORY.split("/")
        return (parent, sub)
        
    def test_vasm_module(self, module):
        """ Check if the module in question is a valid vasm module
        
        Returns True when a module can be loaded on to vasm.
        False otherwise. """
        if not hasattr(module, 'VASM_CATEGORY'):
            return False
        if not hasattr(module, "__vasm_test__"):
            return False
        if not hasattr(module, "__run__"):
            return False
        if not "/" in module.VASM_CATEGORY:
            return False
        return True

    def iconview_key_release(self, iconview):
        children = self.get_parent().get_children()
        categories = []
        for child in children:
            categories.append(child)
        for category in categories:
            if category.iconview != iconview:
                category.iconview.unselect_all()
        return
    
    def iconview_event(self, iconview, event):
        
        children = self.get_parent().get_children()
        categories = []
        for child in children:
            if isinstance(child, SettingsHolder):
                categories.append(child)
        if event.type == gtk.gdk.BUTTON_RELEASE:
            for view in categories:
                if view.iconview != iconview:
                    view.iconview.unselect_all()
            # Now trigger thes tuff
            if iconview.get_selected_items():
                sel = iconview.get_cursor()[0][0]
                actuator = iconview.get_model()[sel][2]
                return actuator(parent=self._parent)
        elif event.type == gtk.gdk.KEY_RELEASE:
            return self.iconview_key_release(iconview)

    def iconview_activate(self, iconview, path):
        children = self.get_parent().get_children()
        categories = []
        for child in children:
            if isinstance(child, SettingsHolder):
                categories.append(child)
        item = path[0]
        actuator = iconview.get_model()[item][2]
        
        for view in categories:
            if view.iconview != iconview:
                view.iconview.unselect_all()
        return actuator(parent=self._parent)
        
    def close_module(self, widget=None, parent=None):
        """ close the module"""
        return self._parent.close_module(self)
    
    def return_to_module(self, widget=None):
        self._parent.return_home()
        return self.launch(parent=self._parent)
    
    def launch(self, widget=None, parent=None):
        self.show_all()
        return self._parent.show_module(self)

class VasmModule(gtk.VBox):
    """ Basic vasm module widget """
    def __init__(self, parent=None, module_title = "",
                 module_desc=""):
        # lets append the title and description first.
        gtk.VBox.__init__(self)
        self._titlelabel = DLabel(
            markup="<b>%s</b>"% module_title
        )
        self.title = module_title
        self._parent = parent
        self._desc_label = DLabel(markup = module_desc)
        titlebox = gtk.HBox()
        titlebox.pack_start(self._titlelabel, True, True, 4)
        descbox = gtk.HBox()
        descbox.pack_start(self._desc_label, True, True, 4)
        self.pack_start(titlebox, False, True, 4)
        self.pack_start(descbox, False, True, 8)
        self.action_area = gtk.HBox()
        #self.pack_end(self.action_area, False, False, 2)
        # the separator
        sep = gtk.HSeparator()
        self.pack_end(sep, False, False, 2)
    
    def set_description(self, markup):
        return self._desc_label.set_markup(markup)
    
    def set_title(self, markup):
        return self._titlelabel.set_markup(markup)        

    def return_to_module(self, caller_widget=None):
        return self._parent.return_to_module(self)
    
    def add_button(self, button):
        """ Add a button to the action area """
        if type(button) is tuple:
        #if type(button) is not gtk.Button:
            bt, cb = button
            bt.connect('clicked', cb)
            return self.action_area.pack_end(bt, False, False, 2)
            
        return self.action_area.pack_end(button, False, False, 2)
    
    def close_module(self, widget=None):
        """ Close this module and return home """
        return self._parent.close_module(self)
    
    def launch(self, widget=None):
        self.show_all()
        return self._parent.show_module(self)

class TextEntry(gtk.HBox):
    def __init__(self, label="", password=False, label_width_chars=0,
                 entry_fill_box=True):
        self._is_password = password
        self.label = gtk.Label()
        self.label.set_use_markup(True)
        self.label.set_markup(label)
        self.entry = gtk.Entry()
        self.entry.set_visibility(not password)
        gtk.HBox.__init__(self)
        self.pack_start(self.label, False, False, 4)
        self.pack_start(self.entry, entry_fill_box, entry_fill_box, 2)
        if label_width_chars > 0:
            self.label.set_property('width-chars', label_width_chars)
        self.label.set_property('xalign', 0.0)
    
    def get_text(self):
        return self.entry.get_text()
    
    def set_text(self, value):
        return self.entry.set_text(value)
    
    def set_label(self, markup):
        return self.label.set_markup(markup)

class HLabeledSpinner(gtk.HBox):
    def __init__(self, label="", spinner_range=59.0):
        gtk.HBox.__init__(self)
        self.label = gtk.Label(label)
        self._adj = gtk.Adjustment(0.0, 0.0, spinner_range, 1.0, 5.0, 0.0)
        self._spinner = gtk.SpinButton(self._adj)
        self._spinner.set_property('numeric', True)
        self.pack_start(self.label, False, True, 2)
        self.pack_start(self._spinner, False, True, 2)

    def get_value(self):
        return self._spinner.get_value()

    def set_value(self, value):
        return self._spinner.set_value(value)

    def set_label(self, label):
        return self.label.set_property('label', label)

class VLabeledSpinner(gtk.VBox):
    def __init__(self, label="", spinner_range=59.0):
        gtk.VBox.__init__(self)
        self.label = gtk.Label(label)
        self.label.set_property('xalign', 0.0)
        self._adj = gtk.Adjustment(0.0, 0.0, spinner_range, 1.0, 5.0, 0.0)
        self._spinner = gtk.SpinButton(self._adj)
        self._spinner.set_property('numeric', True)
        self.pack_start(self.label, False, True, 2)
        self.pack_start(self._spinner, False, True, 2)

    def get_value(self):
        return self._spinner.get_value()

    def set_value(self, value):
        return self._spinner.set_value(value)

    def set_label(self, txt):
        return self.label.set_property('label', txt)

class StackedTimePicker(gtk.HBox):
    def __init__(self):
        gtk.HBox.__init__(self)
        # we'll get 3 boxes and pack them
        self._hrspin = VLabeledSpinner("Hours", spinner_range=23.0)
        self._minspin = VLabeledSpinner("Minutes")
        self._secspin = VLabeledSpinner("Seconds")
        for spinner in (self._hrspin, self._minspin):
            sep = gtk.VSeparator()
            self.pack_start(spinner, False, False, 2)
            self.pack_start(sep, False, False, 0)
        self.pack_start(self._secspin, False, False, 2)
        now = datetime.datetime.now()
        self._hrspin.set_value(now.hour)
        self._minspin.set_value(now.minute)
        self._secspin.set_value(now.second)

class WideTimePicker(gtk.HBox):
    def __init__(self):
        gtk.HBox.__init__(self)
        self._hrspin = HLabeledSpinner("Hours:", spinner_range=23.0)
        self._minspin = HLabeledSpinner("Minutes:")
        self._secspin = HLabeledSpinner("Seconds:")
        for spinner in (self._hrspin, self._minspin, self._secspin):
            self.pack_start(spinner, False, False, 2)
        now = datetime.datetime.now()
        self._hrspin.set_value(now.hour)
        self._minspin.set_value(now.minute)
        self._secspin.set_value(now.second)

    def get_value(self):
        """ Return a tuple with the selected (hour, minute, second) values """
        _hr = int(self._hrspin.get_value())
        _min = int(self._minspin.get_value())
        _sec = int(self._secspin.get_value())
        return (_hr, _min, _sec)

    def set_value(self, value_tuple):
        """ Set the value to the time picker using value_tuple (hr, min, sec)"""
        _hr, _min, _sec = value_tuple
        self._hrspin.set_value(_hr)
        self._minspin.set_value(_min)
        self._secspin.set_value(_sec)
        return
        

class TimePicker(gtk.VBox):
    """ Returns a gtk.HBox holding 3 spinboxes to select the time """
    def __init__(self, orientation = horizontal):
        gtk.VBox.__init__(self)
        box = orientation()
        # create the components.
        box1 = box2 = box3 = gtk.VBox()
        self._hrspin = LabeledSpinner(_("H:"), spinner_range = 23.0)
        self._minspin = LabeledSpinner(_("M:"))
        self._secspin = LabeledSpinner(_("S:"))
        for spinner in (self._hrspin, self._minspin, self._secspin):
           box.pack_start(spinner, False, False, 2)
        # pre-set the values
        now = datetime.datetime.now()
        self._hrspin.set_value(now.hour)
        self._minspin.set_value(now.minute)
        self._secspin.set_value(now.second)
        self.pack_start(box, True, True, 0)
    
    def get_time(self):
        """ Returns a tuple with the selected values for time in (hr, min, sec)"""
        return (int(self._hrspin.get_value()),
                int(self._minspin.get_value()),
                int(self._secspin.get_value()))

class DropdownBox(gtk.HBox):
    """ Labeled dropdown box."""
    def __init__(self, label, choices):
        gtk.HBox.__init__(self)
        if label:
            self.label = gtk.Label()
            self.label.set_use_markup(True)
            self.label.set_markup(label)
            self.label.set_property('xalign', 0.0)
            self.pack_start(self.label, False, False, 2)
        self.selector = gtk.combo_box_new_text()
        for i in choices:
            self.selector.append_text(i)
        self.selector.set_active(0)
        self.pack_start(self.selector, False, True, 2)
        self.selector.set_title("foo")

    def get_value(self):
        return self.selector.get_active_text()

    def get_model(self):
        return self.selector.get_model()

    def set_value(self, value):
        model = self.selector.get_model()
        i = 0
        for item in model:
            if item[0] == value:
                self.selector.set_active(i)
                return
            i += 1
        return

class SettingsHolder(gtk.VBox):
    def __init__(self, label, icon, parent=None):
        gtk.VBox.__init__(self)
        self.label = label
        self._parent = parent
        ivmodel = gtk.ListStore(str, gtk.gdk.Pixbuf, object)
        self.iconview = gtk.IconView()
        self.iconview.set_model(ivmodel)
        self.iconview.set_text_column(0)
        self.iconview.set_pixbuf_column(1)
        self.iconview.set_property('orientation', gtk.ORIENTATION_HORIZONTAL)
        self.iconview.set_columns(2)
        self.iconview.connect('event', self.iconview_event)
        self.iconview.connect('item-activated', self.iconview_activate)
        
        # save the original style settings
        self._original_iv_style=self.iconview.get_style().copy()
        # create the label
        self._label = SettingsLabel(label, icon)
        self.pack_start(self._label, False, True, 4)
        # add the iconview to an eventbox
        self.eventcatcher = gtk.EventBox()
        self.eventcatcher.add(self.iconview)
        self.pack_start(self.eventcatcher, True, True, 4)
    
    def un_highlight(self):
        """ Turns the iconview's colors back to normal """
        orig = gtk.IconView().rc_get_style()
        style = self.iconview.get_style().copy()
        for state in (gtk.STATE_NORMAL,):
            style.base[state] = orig.base[state]
        self.iconview.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#fff"))
        self.iconview.unselect_all()
        return self.iconview.set_style(style)

    def highlight(self):
        children = self.get_parent().get_children()
        for child in children:
            child.un_highlight()        
        style = self.get_style().copy()
        hl_color = self._label.get_colormap().alloc_color("#6d87a3")
        for state in (gtk.STATE_NORMAL,):
            style.base[state] = hl_color
        # unselect all items
        self.iconview.unselect_all()
        self.iconview.set_style(style)
        return


    def add_launcher(self, label, icon, actuator):
        """ Add a launcher to this settings holder"""
        model = self.iconview.get_model()
        if icon.startswith("gtk-"):
            pixbuf = self.iconview.render_icon(
                icon,
                size=gtk.ICON_SIZE_DND,
                detail=None)
        elif icon.startswith("/"):
            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                icon, 32, 32)
        return model.append([label, pixbuf, actuator])


    def iconview_key_release(self, iconview):
        # FIXME: BUG HERE
        children = self.get_parent().get_children()
        categories = []
        for child in children:
            categories.append(child)
        for category in categories:
            if category.iconview != iconview:
                category.iconview.unselect_all()
        return
    
    def iconview_event(self, iconview, event):
        """ capture events for each child in the iconview """
        children = self.get_parent().get_children()
        categories = []
        for child in children:
            if isinstance(child, SettingsHolder):
                categories.append(child)
        if event.type == gtk.gdk.BUTTON_RELEASE:
            for view in categories:
                if view.iconview != iconview:
                    view.iconview.unselect_all()
            # Now trigger thes tuff
            if iconview.get_selected_items():
                sel = iconview.get_cursor()[0][0]
                actuator = iconview.get_model()[sel][2]
                launcher = iconview.get_model()[sel][0]
                logger.debug("Open module \"%s\%s\""% (self.label,launcher))
                return actuator(parent=self._parent)

    def iconview_activate(self, iconview, path):
        children = self.get_parent().get_children()
        categories = []
        for child in children:
            if isinstance(child, SettingsHolder):
                categories.append(child)
        item = path[0]
        actuator = iconview.get_model()[item][2]
        
        for view in categories:
            if view.iconview != iconview:
                view.iconview.unselect_all()
        return actuator(parent=self._parent)

class SettingsLabel(gtk.EventBox):
    def __init__(self, label, icon):
        """ A pre-set settings category separator that produces an event box
        The event box allows us to manipulate the label's appearance (bg color)
        """
        self.label = gtk.Label()
        self.label.set_use_markup(True)
        self.label.set_markup("<b>%s</b>"%_(label))
        
        # set the labels's forecolor
        
        colfg = self.label.get_colormap().alloc_color("white")
        style = self.label.get_style().copy()
        style.fg[gtk.STATE_NORMAL] = colfg
        self.label.set_style(style)
        
        self.icon = gtk.Image()
        if icon.startswith("/"):
            self.icon.set_from_pixbuf(
                gtk.gdk.pixbuf_new_from_file_at_size(icon, 24, 24)
            )
        elif icon.startswith("gtk-"):
            self.icon.set_from_stock(icon, gtk.ICON_SIZE_BUTTON)
        self.holder = gtk.HBox()
        self.holder.pack_start(self.icon, False, False, 4)
        self.holder.pack_start(self.label, False, True, 8)
        gtk.EventBox.__init__(self)
        self.add(self.holder)
        
        # Change the bg color
        colorbg = gtk.gdk.color_parse("#003063")
        self.modify_bg(gtk.STATE_NORMAL, colorbg)
        

class MyStockButton(gtk.Button):
    """ Button that allows us to use a stock icon with a custom label for this
    module """
    def __init__(self, label, icon):
        gtk.Button.__init__(self)
        self.set_label(label)
        self.image = gtk.Image()
        self.image.set_from_stock(icon, gtk.ICON_SIZE_BUTTON)
        self.set_image(self.image)

class DLabel(gtk.Label):
    """ gtk label that resizes and reflows text dinamically when the
    parent window is resized"""
    #__gtype_name__ = "DLabel"
    def __init__(self, markup=None):
        gtk.Label.__init__(self)
        self.set_property('use-markup', True)
        self.__wrap_width = 0
        self.layout = self.get_layout()
        if markup is not None:
            self.set_markup(markup)
        self.set_line_wrap(True)
        self.set_property('xalign', 0.0)

    def do_size_request(self, requisition):
        layout = self.get_layout()
        width, height = layout.get_pixel_size()
        requisition.width = 0
        requisition.height = height

    def do_size_allocate(self, allocation):
        gtk.Label.do_size_allocate(self, allocation)
        self.__set_wrap_width(allocation.width)

    def set_text(self, str):
        gtk.Label.set_text(self, str)
        self.__set_wrap_width(self.__wrap_width)

    def set_markup(self, str):
        gtk.Label.set_markup(self, str)
        self.__set_wrap_width(self.__wrap_width)

    def __set_wrap_width(self, width):
        if width == 0:
            return
        layout = self.get_layout()
        layout.set_width(width*pango.SCALE)
        if self.__wrap_width != width:
            self.__wrap_width = width
            self.queue_resize()