Changeset 996:8035d80d5feb for src/mlx/gui/common.py
- Timestamp:
- 07/04/19 17:57:45 (5 years ago)
- Branch:
- python3
- hg-Phase:
- (<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/common.py
r995 r996 26 26 from gi.repository import GdkPixbuf as gdkPixbuf 27 27 gi.require_version("Gtk", "3.0") 28 from gi.repository import Gtk as gtk28 from gi.repository import Gtk 29 29 try: 30 30 gi.require_version("AppIndicator3", "0.1") … … 36 36 37 37 38 MESSAGETYPE_ERROR = gtk.MessageType.ERROR39 MESSAGETYPE_QUESTION = gtk.MessageType.QUESTION40 MESSAGETYPE_INFO = gtk.MessageType.INFO41 RESPONSETYPE_NONE = gtk.ResponseType.NONE42 RESPONSETYPE_OK = gtk.ResponseType.OK43 RESPONSETYPE_YES = gtk.ResponseType.YES44 RESPONSETYPE_NO = gtk.ResponseType.NO45 RESPONSETYPE_ACCEPT = gtk.ResponseType.ACCEPT46 RESPONSETYPE_REJECT = gtk.ResponseType.REJECT47 RESPONSETYPE_CANCEL = gtk.ResponseType.CANCEL48 ACCEL_VISIBLE = gtk.AccelFlags.VISIBLE38 MESSAGETYPE_ERROR = Gtk.MessageType.ERROR 39 MESSAGETYPE_QUESTION = Gtk.MessageType.QUESTION 40 MESSAGETYPE_INFO = Gtk.MessageType.INFO 41 RESPONSETYPE_NONE = Gtk.ResponseType.NONE 42 RESPONSETYPE_OK = Gtk.ResponseType.OK 43 RESPONSETYPE_YES = Gtk.ResponseType.YES 44 RESPONSETYPE_NO = Gtk.ResponseType.NO 45 RESPONSETYPE_ACCEPT = Gtk.ResponseType.ACCEPT 46 RESPONSETYPE_REJECT = Gtk.ResponseType.REJECT 47 RESPONSETYPE_CANCEL = Gtk.ResponseType.CANCEL 48 ACCEL_VISIBLE = Gtk.AccelFlags.VISIBLE 49 49 CONTROL_MASK = gdk.ModifierType.CONTROL_MASK 50 DIALOG_MODAL = gtk.DialogFlags.MODAL51 WRAP_WORD = gtk.WrapMode.WORD52 JUSTIFY_CENTER = gtk.Justification.CENTER53 JUSTIFY_LEFT = gtk.Justification.LEFT50 DIALOG_MODAL = Gtk.DialogFlags.MODAL 51 WRAP_WORD = Gtk.WrapMode.WORD 52 JUSTIFY_CENTER = Gtk.Justification.CENTER 53 JUSTIFY_LEFT = Gtk.Justification.LEFT 54 54 55 55 CONTROL_MASK = gdk.ModifierType.CONTROL_MASK … … 60 60 SCROLL_DOWN = gdk.ScrollDirection.DOWN 61 61 62 SPIN_USER_DEFINED = gtk.SpinType.USER_DEFINED63 64 FILE_CHOOSER_ACTION_SELECT_FOLDER = gtk.FileChooserAction.SELECT_FOLDER65 FILE_CHOOSER_ACTION_OPEN = gtk.FileChooserAction.OPEN66 FILE_CHOOSER_ACTION_SAVE = gtk.FileChooserAction.SAVE67 68 SELECTION_MULTIPLE = gtk.SelectionMode.MULTIPLE69 70 SHADOW_IN = gtk.ShadowType.IN71 SHADOW_NONE = gtk.ShadowType.NONE72 73 POLICY_AUTOMATIC = gtk.PolicyType.AUTOMATIC74 POLICY_NEVER = gtk.PolicyType.NEVER75 POLICY_ALWAYS = gtk.PolicyType.ALWAYS62 SPIN_USER_DEFINED = Gtk.SpinType.USER_DEFINED 63 64 FILE_CHOOSER_ACTION_SELECT_FOLDER = Gtk.FileChooserAction.SELECT_FOLDER 65 FILE_CHOOSER_ACTION_OPEN = Gtk.FileChooserAction.OPEN 66 FILE_CHOOSER_ACTION_SAVE = Gtk.FileChooserAction.SAVE 67 68 SELECTION_MULTIPLE = Gtk.SelectionMode.MULTIPLE 69 70 SHADOW_IN = Gtk.ShadowType.IN 71 SHADOW_NONE = Gtk.ShadowType.NONE 72 73 POLICY_AUTOMATIC = Gtk.PolicyType.AUTOMATIC 74 POLICY_NEVER = Gtk.PolicyType.NEVER 75 POLICY_ALWAYS = Gtk.PolicyType.ALWAYS 76 76 77 77 WEIGHT_NORMAL = pango.Weight.NORMAL … … 81 81 WINDOW_STATE_WITHDRAWN = gdk.WindowState.WITHDRAWN 82 82 83 SORT_ASCENDING = gtk.SortType.ASCENDING84 SORT_DESCENDING = gtk.SortType.DESCENDING83 SORT_ASCENDING = Gtk.SortType.ASCENDING 84 SORT_DESCENDING = Gtk.SortType.DESCENDING 85 85 86 86 EVENT_BUTTON_PRESS = gdk.EventType.BUTTON_PRESS 87 87 88 TREE_VIEW_COLUMN_FIXED = gtk.TreeViewColumnSizing.FIXED89 90 FILL = gtk.AttachOptions.FILL91 EXPAND = gtk.AttachOptions.EXPAND92 93 UPDATE_IF_VALID = gtk.SpinButtonUpdatePolicy.IF_VALID94 95 SELECTION_MULTIPLE = gtk.SelectionMode.MULTIPLE88 TREE_VIEW_COLUMN_FIXED = Gtk.TreeViewColumnSizing.FIXED 89 90 FILL = Gtk.AttachOptions.FILL 91 EXPAND = Gtk.AttachOptions.EXPAND 92 93 UPDATE_IF_VALID = Gtk.SpinButtonUpdatePolicy.IF_VALID 94 95 SELECTION_MULTIPLE = Gtk.SelectionMode.MULTIPLE 96 96 97 97 pixbuf_new_from_file = gdkPixbuf.Pixbuf.new_from_file … … 139 139 #------------------------------------------------------------------------------ 140 140 141 class IntegerEntry( gtk.Entry):141 class IntegerEntry(Gtk.Entry): 142 142 """An entry that allows only either an empty value, or an integer.""" 143 143 def __init__(self, defaultValue = None): 144 144 """Construct the entry.""" 145 gtk.Entry.__init__(self)145 Gtk.Entry.__init__(self) 146 146 147 147 self.set_alignment(1.0) … … 191 191 #------------------------------------------------------------------------------ 192 192 193 class TimeEntry( gtk.Entry):193 class TimeEntry(Gtk.Entry): 194 194 """Widget to display and edit a time value in HH:MM format.""" 195 195 def __init__(self): … … 296 296 pass 297 297 else: 298 gtk.gdk.display_get_default().beep()298 Gtk.gdk.display_get_default().beep() 299 299 self.stop_emission(signal) 300 300 301 301 #------------------------------------------------------------------------------ 302 302 303 class CredentialsDialog( gtk.Dialog):303 class CredentialsDialog(Gtk.Dialog): 304 304 """A dialog window to ask for a user name and a password.""" 305 305 def __init__(self, gui, userName, password, … … 320 320 contentArea = self.get_content_area() 321 321 322 contentAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,322 contentAlignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5, 323 323 xscale = 0.0, yscale = 0.0) 324 324 contentAlignment.set_padding(padding_top = 4, padding_bottom = 16, … … 327 327 contentArea.pack_start(contentAlignment, False, False, 0) 328 328 329 contentVBox = gtk.VBox()329 contentVBox = Gtk.VBox() 330 330 contentAlignment.add(contentVBox) 331 331 332 332 if infoText is not None: 333 label = gtk.Label(infoText)333 label = Gtk.Label(infoText) 334 334 label.set_alignment(0.0, 0.0) 335 335 336 336 contentVBox.pack_start(label, False, False, 0) 337 337 338 tableAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,338 tableAlignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5, 339 339 xscale = 0.0, yscale = 0.0) 340 340 tableAlignment.set_padding(padding_top = 24, padding_bottom = 0, 341 341 padding_left = 0, padding_right = 0) 342 342 343 table = gtk.Table(3, 2)343 table = Gtk.Table(3, 2) 344 344 table.set_row_spacings(4) 345 345 table.set_col_spacings(16) … … 349 349 contentVBox.pack_start(tableAlignment, True, True, 0) 350 350 351 label = gtk.Label(userNameLabel)351 label = Gtk.Label(userNameLabel) 352 352 label.set_use_underline(True) 353 353 label.set_alignment(0.0, 0.5) 354 354 table.attach(label, 0, 1, 0, 1) 355 355 356 self._userName = gtk.Entry()356 self._userName = Gtk.Entry() 357 357 self._userName.set_width_chars(16) 358 358 # FIXME: enabled the OK button only when there is something in thr … … 365 365 label.set_mnemonic_widget(self._userName) 366 366 367 label = gtk.Label(passwordLabel)367 label = Gtk.Label(passwordLabel) 368 368 label.set_use_underline(True) 369 369 label.set_alignment(0.0, 0.5) 370 370 table.attach(label, 0, 1, 1, 2) 371 371 372 self._password = gtk.Entry()372 self._password = Gtk.Entry() 373 373 self._password.set_visibility(False) 374 374 #self._password.connect("changed", … … 380 380 381 381 if rememberPassword is not None: 382 self._rememberButton = gtk.CheckButton(rememberLabel)382 self._rememberButton = Gtk.CheckButton(rememberLabel) 383 383 self._rememberButton.set_use_underline(True) 384 384 self._rememberButton.set_tooltip_text(rememberTooltip) … … 522 522 523 523 Return a boolean indicating the answer.""" 524 dialog = gtk.MessageDialog(parent = parent,524 dialog = Gtk.MessageDialog(parent = parent, 525 525 type = MESSAGETYPE_QUESTION, 526 526 message_format = question) … … 540 540 title = WINDOW_TITLE_BASE): 541 541 """Display an error dialog box with the given message.""" 542 dialog = gtk.MessageDialog(parent = parent,542 dialog = Gtk.MessageDialog(parent = parent, 543 543 type = MESSAGETYPE_ERROR, 544 544 message_format = message) … … 562 562 563 563 def createFlightTypeComboBox(): 564 flightTypeModel = gtk.ListStore(str, int)564 flightTypeModel = Gtk.ListStore(str, int) 565 565 for type in _const.flightTypes: 566 566 name = "flighttype_" + _const.flightType2string(type) 567 567 flightTypeModel.append([xstr(name), type]) 568 568 569 flightType = gtk.ComboBox(model = flightTypeModel)570 renderer = gtk.CellRendererText()569 flightType = Gtk.ComboBox(model = flightTypeModel) 570 renderer = Gtk.CellRendererText() 571 571 flightType.pack_start(renderer, True) 572 572 flightType.add_attribute(renderer, "text", 0)
Note:
See TracChangeset
for help on using the changeset viewer.