def test_from_model_index_out_of_bounds(): ''' Ensure that if a gtk.ComboBoxEntry is created with an index that is out of bounds for the model, then a GtkWarning is shown. ''' store = gtk.ListStore(int, int, int) # Only index 0..2 is valid. gtk.combo_box_entry_new_with_model(store, 3)
def test_combobox_entry(self): liststore = gtk.ListStore(int, str) liststore.append((1, 'One')) liststore.append((2, 'Two')) liststore.append((3, 'Three')) # might cause a Pango warning, do not break on this old_mask = GLib.log_set_always_fatal(GLib.LogLevelFlags.LEVEL_CRITICAL | GLib.LogLevelFlags.LEVEL_ERROR) try: combo = gtk.ComboBoxEntry(model=liststore) finally: GLib.log_set_always_fatal(old_mask) combo.set_text_column(1) combo.set_active(0) self.assertEqual(combo.get_text_column(), 1) self.assertEqual(combo.get_child().get_text(), 'One') combo = gtk.combo_box_entry_new() combo.set_model(liststore) combo.set_text_column(1) combo.set_active(0) self.assertEqual(combo.get_text_column(), 1) self.assertEqual(combo.get_child().get_text(), 'One') combo = gtk.combo_box_entry_new_with_model(liststore) combo.set_text_column(1) combo.set_active(0) self.assertEqual(combo.get_text_column(), 1) self.assertEqual(combo.get_child().get_text(), 'One')
def testComboBoxEntry(self): liststore = gtk.ListStore(int, str) liststore.append((1, 'One')) liststore.append((2, 'Two')) liststore.append((3, 'Three')) # might cause a Pango warning, do not break on this old_mask = GLib.log_set_always_fatal( GLib.LogLevelFlags.LEVEL_CRITICAL | GLib.LogLevelFlags.LEVEL_ERROR) combo = gtk.ComboBoxEntry(model=liststore) GLib.log_set_always_fatal(old_mask) combo.set_text_column(1) combo.set_active(0) self.assertEqual(combo.get_text_column(), 1) self.assertEqual(combo.get_child().get_text(), 'One') combo = gtk.combo_box_entry_new() combo.set_model(liststore) combo.set_text_column(1) combo.set_active(0) self.assertEqual(combo.get_text_column(), 1) self.assertEqual(combo.get_child().get_text(), 'One') combo = gtk.combo_box_entry_new_with_model(liststore) combo.set_text_column(1) combo.set_active(0) self.assertEqual(combo.get_text_column(), 1) self.assertEqual(combo.get_child().get_text(), 'One')
def log_user(self, bt): dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, None) dialog.set_alternative_button_order( [gtk.RESPONSE_CANCEL, gtk.RESPONSE_OK]) dialog.set_default_response(2) dialog.set_markup('Dispecer:') store = gtk.ListStore(str) for n in self.agenda.dis: store.append([n]) entry = gtk.combo_box_entry_new_with_model(store, 0) entry.child.set_text(env.last_user) entry.show_all() dialog.vbox.pack_end(entry, True, True, 0) dialog.set_position(gtk.WIN_POS_CENTER) dialog.show_all() resp = dialog.run() text = unicode(entry.get_active_text()) dialog.destroy() if resp == gtk.RESPONSE_OK: if not text: return ou = context.USER context.USER = text env.last_user = text self.userbt.child.set_text(text) env.log('dispecer', 'old', ou, 'new', text)
def on_raport_agent(self, _): dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK_CANCEL, None) dialog.set_alternative_button_order( [gtk.RESPONSE_CANCEL, gtk.RESPONSE_OK]) dialog.set_default_response(2) dialog.set_markup('Raport <b>agent</b>:') dialog.set_position(gtk.WIN_POS_CENTER) entry = gtk.combo_box_entry_new_with_model( self.agent_store, 0) # self.autocomp() # gtk.Entry() # entry.set_model(self.agent_store) # entry.connect("activate", resp_to_dialog, dialog, gtk.RESPONSE_OK) set_autocomp(entry.child, self.match, self.agent_store) entry.show_all() v = gtk.VBox(False, 5) hbox = gtk.HBox(False, 5) hbox.pack_start(gtk.Label("Nume:"), False, 5, 5) hbox.pack_end(entry) v.add(hbox) y_adj = gtk.Adjustment(2018, 2000, 2024, 1, 10, 0) sp_y = gtk.SpinButton(y_adj, 1, 0) sp_y.set_numeric(True) sp_y.set_size_request(60, 27) h = gtk.HBox(False, 5) h.pack_start(gtk.Label('An:'), False, True) h.pack_start(sp_y, False, True) m_adj = gtk.Adjustment(0, 0, 12, 1, 10, 0) sp_m = gtk.SpinButton(m_adj, 1, 0) sp_m.set_numeric(True) sp_m.set_size_request(60, 27) h.add(gtk.Label('Luna:')) h.pack_end(sp_m, False, True) v.add(h) v.add(gtk.Label('(0 pentru întreaga perioadă)')) # dialog.format_secondary_markup("Adăugți un <i>agent</i>") dialog.vbox.pack_end(v, True, True, 0) dialog.show_all() resp = dialog.run() # text = unicode(entry.get_text()) text = unicode(entry.get_active_text()) month = sp_m.get_value_as_int() year = sp_y.get_value_as_int() dialog.destroy() if resp == gtk.RESPONSE_OK: r = self.disp.raport_agent(unicode(text), month, year) if r == 0: self.set_status('Raport generat!') else: self.set_status('Err {}'.format(r), '#c00') raise ValueError('Err on_raport_agent', r, text)
def testComboBoxEntry(self): liststore = gtk.ListStore(int, str) liststore.append((1, 'One')) liststore.append((2, 'Two')) liststore.append((3, 'Three')) combo = gtk.ComboBoxEntry(model=liststore) combo.set_text_column(1) combo.set_active(0) self.assertEquals(combo.get_text_column(), 1) self.assertEquals(combo.get_child().get_text(), 'One') combo = gtk.combo_box_entry_new() combo.set_model(liststore) combo.set_text_column(1) combo.set_active(0) self.assertEquals(combo.get_text_column(), 1) self.assertEquals(combo.get_child().get_text(), 'One') combo = gtk.combo_box_entry_new_with_model(liststore) combo.set_text_column(1) combo.set_active(0) self.assertEquals(combo.get_text_column(), 1) self.assertEquals(combo.get_child().get_text(), 'One')
def testComboBoxEntry(self): liststore = gtk.ListStore(int, str) liststore.append((1, 'One')) liststore.append((2, 'Two')) liststore.append((3, 'Three')) combo = gtk.ComboBoxEntry(model=liststore) combo.set_text_column(1) combo.set_active(0) self.assertEqual(combo.get_text_column(), 1) self.assertEqual(combo.get_child().get_text(), 'One') combo = gtk.combo_box_entry_new() combo.set_model(liststore) combo.set_text_column(1) combo.set_active(0) self.assertEqual(combo.get_text_column(), 1) self.assertEqual(combo.get_child().get_text(), 'One') combo = gtk.combo_box_entry_new_with_model(liststore) combo.set_text_column(1) combo.set_active(0) self.assertEqual(combo.get_text_column(), 1) self.assertEqual(combo.get_child().get_text(), 'One')
def test_combobox_entry(self): liststore = gtk.ListStore(int, str) liststore.append((1, 'One')) liststore.append((2, 'Two')) liststore.append((3, 'Three')) # might cause a Pango warning, do not break on this with capture_glib_warnings(allow_warnings=True): combo = gtk.ComboBoxEntry(model=liststore) combo.set_text_column(1) combo.set_active(0) self.assertEqual(combo.get_text_column(), 1) self.assertEqual(combo.get_child().get_text(), 'One') combo = gtk.combo_box_entry_new() combo.set_model(liststore) combo.set_text_column(1) combo.set_active(0) self.assertEqual(combo.get_text_column(), 1) self.assertEqual(combo.get_child().get_text(), 'One') combo = gtk.combo_box_entry_new_with_model(liststore) combo.set_text_column(1) combo.set_active(0) self.assertEqual(combo.get_text_column(), 1) self.assertEqual(combo.get_child().get_text(), 'One')