我们从Python开源项目中,提取了以下39个代码示例,用于说明如何使用gtk.Dialog()。
def __init__(self, title, parent, ok_button=True, cancel_button=True, width=600, height=260, extra_buttons=None): buttons = [] if extra_buttons: buttons.extend(extra_buttons) if ok_button: buttons.extend([gtk.STOCK_OK, gtk.RESPONSE_ACCEPT]) if cancel_button: buttons.extend([gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT]) buttons = tuple(buttons) gtk.Dialog.__init__(self, title, parent, DEF_DIALOG_FLAGS, buttons) self.set_size_request(width, height) self.set_has_separator(False) # __init__() # Dialog
def quit(self, widget, event=None): """Asks if user would like to save file before quitting, then quits the program.""" if self.toSave: if self.oneConfigFile: response = gtk.RESPONSE_YES else: dialog = gtk.Dialog("Save config?", self, gtk.DIALOG_MODAL, (gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) dialog.get_content_area().add(gtk.Label("Save config before quitting?")) dialog.get_content_area().set_size_request(300, 100) dialog.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return True # Return True to stop it quitting when we hit "Cancel" elif response == gtk.RESPONSE_NO: gtk.main_quit() elif response == gtk.RESPONSE_YES: self.save() gtk.main_quit() else: gtk.main_quit()
def __init__(self, parent): gtk.Dialog.__init__(self, "Rename", parent, 0) self.set_default_size(150, 100) label1=gtk.Label() label1.set_markup("Enter New Name") self.newname=gtk.Entry() box = self.get_content_area() box.add(label1) box.add(self.newname) self.ok_button=gtk.Button("OK") box.add(self.ok_button) self.ok_button.connect("clicked",self.on_rename_ok_clicked) self.show_all()
def __init__(self, rthread, parent=None): gtk.Dialog.__init__(self, title=_("Shift"), buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_OK)) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.rthread = rthread self.__prog = gtk.ProgressBar() self.__prog.show() self.__labl = gtk.Label("") self.__labl.show() self.vbox.pack_start(self.__prog, 1, 1, 1) self.vbox.pack_start(self.__labl, 0, 0, 0) self.quiet = False self.thread = None
def __init__(self, **args): buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK) gtk.Dialog.__init__(self, buttons=buttons, **args) self.label = gtk.Label() self.label.set_size_request(300, 100) # pylint: disable-msg=E1101 self.vbox.pack_start(self.label, 1, 1, 0) self.text = gtk.Entry() self.text.connect("activate", self.respond_ok, None) # pylint: disable-msg=E1101 self.vbox.pack_start(self.text, 1, 1, 0) self.label.show() self.text.show()
def __init__(self, choices, **args): buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK) gtk.Dialog.__init__(self, buttons=buttons, **args) self.label = gtk.Label() self.label.set_size_request(300, 100) # pylint: disable-msg=E1101 self.vbox.pack_start(self.label, 1, 1, 0) self.label.show() try: default = choices[0] except IndexError: default = None self.choice = make_choice(sorted(choices), self.editable, default) # pylint: disable-msg=E1101 self.vbox.pack_start(self.choice, 1, 1, 0) self.choice.show() self.set_default_response(gtk.RESPONSE_OK)
def delete_format(self, widget, data=None): # ???? ???????? gtk.RadioButton for format_id in self.format_radio: if format_id.get_active(): # ?????????? ??????, ? ??????? ???????? ???????????? ?????????? ???? ????? dialog = gtk.Dialog('???????? ??????? "' + self.data['formats'][self.format_radio.index(format_id)]['name'] + '"', self.window, gtk.DIALOG_NO_SEPARATOR | gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_NO, gtk.RESPONSE_CANCEL, gtk.STOCK_YES, gtk.RESPONSE_OK)) dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS) dialog.set_resizable(False) dialog.set_border_width(10) self.confirmation_label = gtk.Label('?? ????????????? ?????? ??????? ?????? "' + self.data['formats'][self.format_radio.index(format_id)]['name'] + '"?') dialog.vbox.pack_start(self.confirmation_label, True, True, 5) dialog.show_all() response = dialog.run() if response == gtk.RESPONSE_CANCEL: dialog.hide() dialog.destroy() if response == gtk.RESPONSE_OK: # ??????? ?????? name = self.data['formats'][self.format_radio.index(format_id)]['name'] del self.data['formats'][self.format_radio.index(format_id)] config = open(self.path, 'wb') json.dump(self.data, config) config.close() self.format_radio[self.format_radio.index(format_id)].hide() if len(self.format_radio) == 1: pass elif self.format_radio.index(format_id) + 1 <= len(self.format_radio) - 1: self.format_radio[self.format_radio.index(format_id) + 1].set_active(True) elif self.format_radio.index(format_id) + 1 > len(self.format_radio) - 1: self.format_radio[self.format_radio.index(format_id) - 1].set_active(True) del self.format_radio[self.format_radio.index(format_id)] if len(self.format_radio) < 1: self.delete_button.set_sensitive(False) self.edit_button.set_sensitive(False) self.add_success_label.set_markup('<span foreground="#008600">"' + str(name) + '" ??????? ??????\n</span>') dialog.hide() dialog.destroy() break # ??? ??????? ???????????? ?????????? ?????? ???????
def get_password(self,parent): dialog = gtk.Dialog("Configure System Password",parent,gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,(gtk.STOCK_CANCEL,gtk.RESPONSE_REJECT,gtk.STOCK_OK,gtk.RESPONSE_ACCEPT)) self.pass1 = gtk.HBox() self.label1 = gtk.Label(" Passsword: ") self.pass1.pack_start(self.label1,False,True,0) self.password1 = gtk.Entry() self.password1.set_visibility(False) self.pass1.pack_start(self.password1,False,True,0) dialog.vbox.add(self.pass1) self.pass2 = gtk.HBox() self.label2 = gtk.Label(" Verify Password: ") self.pass2.pack_start(self.label2,False,True,0) self.password2 = gtk.Entry() self.password2.set_visibility(False) self.pass2.pack_start(self.password2,False,True,0) dialog.vbox.add(self.pass2) dialog.show_all() response = dialog.run() if response == gtk.RESPONSE_ACCEPT: self.a = self.password1.get_text() self.b = self.password2.get_text() dialog.destroy() else: self.a = '' self.b = '' dialog.destroy() # Configure Network Dialog
def __init__(self, visualizer, node_index, statistics_collector): InformationWindow.__init__(self) self.win = gtk.Dialog(parent=visualizer.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR, buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) self.win.connect("response", self._response_cb) self.win.set_title("Statistics for node %i" % node_index) self.visualizer = visualizer self.statistics_collector = statistics_collector self.node_index = node_index self.viz_node = visualizer.get_node(node_index) self.table_model = gtk.ListStore(*([str]*13)) treeview = gtk.TreeView(self.table_model) treeview.show() self.win.vbox.add(treeview) def add_column(descr, colid): column = gtk.TreeViewColumn(descr, gtk.CellRendererText(), text=colid) treeview.append_column(column) add_column("Interface", self.COLUMN_INTERFACE) add_column("Tx Packets", self.COLUMN_TX_PACKETS) add_column("Tx Bytes", self.COLUMN_TX_BYTES) add_column("Tx pkt/1s", self.COLUMN_TX_PACKET_RATE) add_column("Tx bit/1s", self.COLUMN_TX_BIT_RATE) add_column("Rx Packets", self.COLUMN_RX_PACKETS) add_column("Rx Bytes", self.COLUMN_RX_BYTES) add_column("Rx pkt/1s", self.COLUMN_RX_PACKET_RATE) add_column("Rx bit/1s", self.COLUMN_RX_BIT_RATE) self.visualizer.add_information_window(self) self.win.show()
def begin(): begin_dialog = gtk.Dialog(); begin_dialog_entry = gtk.Entry(); begin_dialog.add_action_widget(begin_dialog_entry,0); begin_dialog.add_button("OK",1); begin_dialog.add_button("CANCEL",2); begin_dialog.connect("response",begin_response); begin_dialog_entry.show(); begin_dialog.run();
def select_Server(self,widget,event,pattern,): if pattern == 1:#?? for key in self.serverInfo: self.serverInfo[key]['checkButton'].set_active(True); elif pattern == 2:#?? for key in self.serverInfo: if self.serverInfo[key]['checkButton'].get_active(): self.serverInfo[key]['checkButton'].set_active(False); else: self.serverInfo[key]['checkButton'].set_active(True); elif pattern ==3: def get_response(dialog,response_id): if response_id == 1: regex = dialog.get_action_area().get_children()[2].get_text(); for key in self.serverInfo: s = re.match(regex,self.serverInfo[key]['serverName']) print s if s: self.serverInfo[key]['checkButton'].set_active(False); else: self.serverInfo[key]['checkButton'].set_active(True); else: show_message("The script has exited.","Information"); dialog.destroy(); begin_dialog = gtk.Dialog(); begin_dialog_entry = gtk.Entry(); begin_dialog.set_title("???????????") begin_dialog.add_action_widget(begin_dialog_entry,0); begin_dialog.add_button("OK",1); begin_dialog.add_button("CANCEL",2); begin_dialog.connect("response",get_response); begin_dialog_entry.show(); begin_dialog.run();
def add_Server(self,widget,event): begin_dialog = gtk.Dialog(); begin_dialog_entry = gtk.Entry(); begin_dialog.set_title("???????????") begin_dialog.add_action_widget(begin_dialog_entry,0); begin_dialog.add_button("OK",1); begin_dialog.add_button("CANCEL",2); begin_dialog.connect("response",self.get_Addresponse); begin_dialog_entry.show(); begin_dialog.run();
def exitfc_button_cb(self, button): label = gtk.Label("Are you sure you want the FC to exit?") dialog = gtk.Dialog("Confirm Exit", None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) dialog.vbox.pack_start(label) label.show() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_ACCEPT: msg = ZarjExitCommand() self.zarj_comm.push_message(msg)
def mess_with_buttons(mess, buttons, title = ""): mwb = gtk.Dialog(parent = None, buttons = buttons, flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, ) mwb.set_title(title) finbox = mwb.get_content_area() l = gtk.Label(mess) finbox.pack_start(l) mwb.set_keep_above(True) mwb.show_all() response = mwb.run() mwb.hide() mwb.destroy() return response
def edit_string(self, time_out = 0.05): self.stringedit_window = gtk.Dialog(parent = self.tv.get_toplevel()) self.stringedit_window.hide() self.stringedit_window.set_decorated(False) self.stringedit_window.set_transient_for(None) self.stringedit_window.set_border_width(0) self.stringedit_window.set_property("skip-taskbar-hint", True) self.stringedit_entry = gtk.Entry() self.stringedit_window.vbox.add(self.stringedit_entry) self.stringedit_entry.set_editable(True) self.stringedit_entry.connect('key-press-event', self.string_edit_keyhandler) # position the popup on the edited cell (tree_x, tree_y) = self.tv.get_bin_window().get_origin() (tree_w, tree_h) = self.tv.window.get_geometry()[2:4] x = tree_x + self.cell_area.x y = tree_y + self.cell_area.y self.stringedit_window.move(x - 4, y - 2) self.stringedit_window.resize(tree_w - self.cell_area.x + 4, self.cell_area.height) self.stringedit_window.show_all() self.stringedit_entry.grab_focus() self.stringedit_entry.connect('focus-out-event', self.string_edit_focus_out) time.sleep(time_out) if self.inputKey != 'BS' : self.stringedit_entry.set_text(self.param_value) self.inputKey = '' response = self.stringedit_window.run() new_val = self.stringedit_entry.get_text() self.stringedit_window.hide() self.stringedit_window.destroy() return response, new_val
def __init__(self, dialog_type=DialogTypes.YES_NO): """ 0 = yes/no, 1 = ok/cancel, 2 = error """ super(Dialogs, self).__init__() # Initialize the gtk.Dialog super class # Glade setup if dialog_type == DialogTypes.YES_NO or dialog_type == DialogTypes.OK_CANCEL: gladefile = os.path.join(UIDIR, 'dialog.glade') else: gladefile = os.path.join(UIDIR, 'error_dialog.glade') self.builder = gtk.Builder() self.builder.add_from_file(gladefile) self.builder.connect_signals(self) self.dialog_window = self.builder.get_object("window") self.message_label = self.builder.get_object("mesage_label") self.running = False self.result = False if dialog_type == DialogTypes.YES_NO: self.builder.get_object("button1").set_label("YES") self.builder.get_object("button2").set_label("NO") elif dialog_type == DialogTypes.OK_CANCEL: self.builder.get_object("button1").set_label("OK") self.builder.get_object("button2").set_label("CANCEL")
def run(self, message): """ Show the Dialog only if not already running """ if not self.running: self.running = True self.message_label.set_text(message) self.dialog_window.show() gtk.main() self.running = False return self.result
def __init__(self, window, title='', message=''): self.status = False self.dialog = gtk.Dialog(title, window, gtk.DIALOG_MODAL, ()) self.dialog.set_urgency_hint(False) self.label = gtk.Label() self.label.set_markup(message) self.dialog.vbox.pack_start(self.label) self.progress = gtk.ProgressBar() self.progress.set_pulse_step(0.01) self.dialog.vbox.pack_start(self.progress, False, False) self.button = gtk.Button(_("Cancel"), gtk.STOCK_CANCEL) self.button.connect("clicked", self.callback) self.dialog.vbox.pack_start(self.button, False, False) self.dialog.show_all()
def __init__(self, window): self.dialog = gtk.Dialog('Debug Window', window, gtk.DIALOG_MODAL, ()) self.dialog.set_destroy_with_parent(True) self.dialog.set_transient_for(window) self.dialog.set_modal(False) self.textview = gtk.TextView() self.textview.set_editable(False) self.textview.set_wrap_mode(gtk.WRAP_WORD_CHAR) self.textview.set_scroll_adjustments(gtk.Adjustment(1.0, 1.0, 100.0, 1.0, 10.0, 10.0), gtk.Adjustment(1.0, 1.0, 100.0, 1.0, 10.0, 10.0)) self.scrolledwindow = gtk.ScrolledWindow(None, None) self.scrolledwindow.add(self.textview) self.dialog.vbox.pack_start(self.scrolledwindow) self.dialog.set_default_size(640, 480)
def __init__(self, title, message, default_text='', modal=True, mask=False): gtk.Dialog.__init__(self) self.set_title(title) self.connect("destroy", self.quit) self.connect("delete_event", self.quit) if modal: self.set_modal(True) box = gtk.VBox(spacing=10) box.set_border_width(10) self.vbox.pack_start(box) box.show() if message: label = gtk.Label(message) box.pack_start(label) label.show() self.entry = gtk.Entry() self.entry.set_text(default_text) self.entry.set_visibility(not mask) box.pack_start(self.entry) self.entry.show() self.entry.grab_focus() button = gtk.Button(stock=gtk.STOCK_OK) button.connect("clicked", self.click) self.entry.connect("activate", self.click) button.set_flags(gtk.CAN_DEFAULT) self.action_area.pack_start(button) button.show() button.grab_default() button = gtk.Button(stock=gtk.STOCK_CANCEL) button.connect("clicked", self.quit) button.set_flags(gtk.CAN_DEFAULT) self.action_area.pack_start(button) button.show() self.ret = None
def __init__(self, parent): gtk.Dialog.__init__(self, "About ProjectX", parent, 0) self.set_default_size(150, 100) label1=gtk.Label() label1.set_markup("ProjectX lets you organize files and folders on your computer :)") label1.set_line_wrap(True) label = gtk.Label() label.set_markup(" Developed by Avneet Singh Saluja, Ayudh Kumar Gupta, Ayur Jain, Ayush Garg, Ayush Rohatgi ") label2=gtk.Label() label2.set_markup("V 1.0") label2.set_line_wrap(True) box = self.get_content_area() box.add(label1) box.add(label2) box.add(label) self.ok_button=gtk.Button("OK") box.add(self.ok_button) self.ok_button.connect("clicked",self.closer) self.show_all()
def __init__(self, parent): gtk.Dialog.__init__(self, "Properties", parent, 0) self.set_default_size(150, 100) a=os.path.getsize(selected_path_for_prop) a=str(a/1024000.00) b=os.path.basename(selected_path_for_prop) label1=gtk.Label() label1.set_markup(" Name: "+b+" ") label1.set_line_wrap(True) label2=gtk.Label() label2.set_markup(" Size: "+a+"MB ") label2.set_line_wrap(True) label3=gtk.Label() label3.set_markup(" Directory: "+selected_path_for_prop+" ") label3.set_line_wrap(True) box = self.get_content_area() box.add(label1) box.add(label2) box.add(label3) self.ok_button=gtk.Button("OK") box.add(self.ok_button) self.ok_button.connect("clicked",self.closer) self.show_all()
def __init__(self, parent): gtk.Dialog.__init__(self, "New Folder", parent, 0) self.set_default_size(150, 100) label1=gtk.Label() label1.set_markup("Enter New Folder's Name") self.newname=gtk.Entry() box = self.get_content_area() box.add(label1) box.add(self.newname) self.ok_button=gtk.Button("OK") box.add(self.ok_button) self.ok_button.connect("clicked",self.on_newfolder_ok_clicked) self.show_all()
def on_newfolder_clicked(self,widget): dialog = newfoldername(self) gtk.Dialog.run(dialog) new_folder_path = self.current_directory + os.path.sep + new_name print new_folder_path os.mkdir(new_folder_path,0755) self.fill_store()
def __init__(self,title="Config",parent=None,config = None): gtk.Dialog.__init__(self,title,parent, gtk.DIALOG_DESTROY_WITH_PARENT, ('Apply',gtk.RESPONSE_APPLY,'Cancel',gtk.RESPONSE_CANCEL)) self.set_keep_above(True) self.set_position(gtk.WIN_POS_CENTER) self.last_config= config # settings self.atual_config = config # setup all widgets self._setup_widgets()
def _do_manual_select(self, filename): radiolist = {} for drv, radio in directory.DRV_TO_RADIO.items(): if not issubclass(radio, chirp_common.CloneModeRadio): continue radiolist["%s %s" % (radio.VENDOR, radio.MODEL)] = drv lab = gtk.Label("""<b><big>Unable to detect model!</big></b> If you think that it is valid, you can select a radio model below to force an open attempt. If selecting the model manually works, please file a bug on the website and attach your image. If selecting the model does not work, it is likely that you are trying to open some other type of file. """) lab.set_justify(gtk.JUSTIFY_FILL) lab.set_line_wrap(True) lab.set_use_markup(True) lab.show() choice = miscwidgets.make_choice(sorted(radiolist.keys()), False, sorted(radiolist.keys())[0]) d = gtk.Dialog(title="Detection Failed", buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) d.vbox.pack_start(lab, 0, 0, 0) d.vbox.pack_start(choice, 0, 0, 0) d.vbox.set_spacing(5) choice.show() d.set_default_size(400, 200) # d.set_resizable(False) r = d.run() d.destroy() if r != gtk.RESPONSE_OK: return try: rc = directory.DRV_TO_RADIO[radiolist[choice.get_active_text()]] return rc(filename) except: return
def __init__(self, title="", parent=None, buttons=None): gtk.Dialog.__init__(self, title=title, parent=parent, buttons=buttons) self._label = gtk.Label("") self._label.show() # pylint: disable-msg=E1101 self.vbox.pack_start(self._label, 1, 1, 1)
def delete(self, newhole, quiet=False, all=False): self.quiet = quiet self.thread = threading.Thread(target=self.threadfn, args=(newhole, self._delete_hole, all)) self.thread.start() gtk.Dialog.run(self)
def __init__(self, settings=None, parent=None, title=_("Radio")): buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK) gtk.Dialog.__init__(self, title, parent=parent, flags=gtk.DIALOG_MODAL) self.__make_ui(settings) self.__cancel_button = self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) self.__okay_button = self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) self.__okay_button.grab_default() self.__okay_button.grab_focus()
def __init__(self, **kwargs): if "buttons" not in kwargs.keys(): kwargs["buttons"] = (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) self.__fields = {} self.set_default_response(gtk.RESPONSE_OK) gtk.Dialog.__init__(self, **kwargs)
def __init__(self, filename): gtk.Dialog.__init__(self, buttons=(_("Overwrite"), gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) self.set_property("text", _("File Exists")) text = \ _("The file {name} already exists. " "Do you want to overwrite it?").format(name=filename) self.format_secondary_text(text)
def __init__(self, visualizer, node_index): InformationWindow.__init__(self) self.win = gtk.Dialog(parent=visualizer.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR, buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) self.win.set_default_size(gtk.gdk.screen_width()/2, gtk.gdk.screen_height()/2) self.win.connect("response", self._response_cb) self.win.set_title("OLSR routing table for node %i" % node_index) self.visualizer = visualizer self.node_index = node_index self.table_model = gtk.ListStore(str, str, str, int) treeview = gtk.TreeView(self.table_model) treeview.show() sw = gtk.ScrolledWindow() sw.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC, vscrollbar_policy=gtk.POLICY_AUTOMATIC) sw.show() sw.add(treeview) self.win.vbox.add(sw) # Dest. column = gtk.TreeViewColumn('Destination', gtk.CellRendererText(), text=self.COLUMN_DESTINATION) treeview.append_column(column) # Next hop column = gtk.TreeViewColumn('Next hop', gtk.CellRendererText(), text=self.COLUMN_NEXT_HOP) treeview.append_column(column) # Interface column = gtk.TreeViewColumn('Interface', gtk.CellRendererText(), text=self.COLUMN_INTERFACE) treeview.append_column(column) # Num. Hops column = gtk.TreeViewColumn('Num. Hops', gtk.CellRendererText(), text=self.COLUMN_NUM_HOPS) treeview.append_column(column) self.visualizer.add_information_window(self) self.win.show()
def __init__(self, visualizer, node_index): InformationWindow.__init__(self) self.win = gtk.Dialog(parent=visualizer.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR, buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) self.win.connect("response", self._response_cb) self.win.set_title("IPv4 routing table for node %i" % node_index) self.visualizer = visualizer self.node_index = node_index self.table_model = gtk.ListStore(str, str, str, str, int) treeview = gtk.TreeView(self.table_model) treeview.show() sw = gtk.ScrolledWindow() sw.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC, vscrollbar_policy=gtk.POLICY_AUTOMATIC) sw.show() sw.add(treeview) self.win.vbox.add(sw) self.win.set_default_size(600, 300) # Dest. column = gtk.TreeViewColumn('Destination', gtk.CellRendererText(), text=self.COLUMN_DESTINATION) treeview.append_column(column) # Next hop column = gtk.TreeViewColumn('Next hop', gtk.CellRendererText(), text=self.COLUMN_NEXT_HOP) treeview.append_column(column) # Interface column = gtk.TreeViewColumn('Interface', gtk.CellRendererText(), text=self.COLUMN_INTERFACE) treeview.append_column(column) # Type column = gtk.TreeViewColumn('Type', gtk.CellRendererText(), text=self.COLUMN_TYPE) treeview.append_column(column) # Prio column = gtk.TreeViewColumn('Prio', gtk.CellRendererText(), text=self.COLUMN_PRIO) treeview.append_column(column) self.visualizer.add_information_window(self) self.win.show()
def save_shot(self): # create a new window dialog = gtk.Dialog("Manual ScreenShot", None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) dialog.set_size_request(400, 250) dialog.set_title("Manual ScreenShot Comment ECEL V2.0") table = gtk.Table(5,2,False) table.show() # create ip row ipLabel = gtk.Label("IP") ipEntry = gtk.Entry() table.attach(ipLabel, 0, 1, 0, 1) table.attach(ipEntry, 1, 2, 0, 1) ipLabel.show() ipEntry.show() # create Port row portLabel = gtk.Label("Port") portEntry = gtk.Entry() table.attach(portLabel, 0, 1, 1, 2) table.attach(portEntry, 1, 2, 1, 2) portLabel.show() portEntry.show() # create initial row initialLabel = gtk.Label("Initials") initialEntry = gtk.Entry() table.attach(initialLabel, 0, 1, 2, 3) table.attach(initialEntry, 1, 2, 2, 3) initialLabel.show() initialEntry.show() #create the comment entry field maxChar = 64 commentEntry = gtk.Entry() commentEntry.set_max_length(maxChar) commentEntry.insert_text("Enter Comment") commentEntry.select_region(0, len(commentEntry.get_text())) table.attach(commentEntry, 0, 2, 3, 4) commentEntry.show() dialog.vbox.pack_start(table) response = dialog.run() self.ip_entry_text = ipEntry.get_text() self.port_entry_text = portEntry.get_text() self.initial_entry_text = initialEntry.get_text() self.comment_entry_text = commentEntry.get_text() dialog.hide_all() dialog.destroy() return response
def cb_ok(self, widget, data=None): buf = self._text.get_buffer() self.text = buf.get_text(buf.get_start_iter(), buf.get_end_iter()) if isinstance(self._preamble, gtk.FileChooser): self.preamble_file = self._preamble.get_filename() if not self.preamble_file: self.preamble_file = "" else: self.preamble_file = self._preamble.get_text() if self.scale_factor is not None: self.scale_factor = self._scale_adj.get_value() try: self.callback(self.text, self.preamble_file, self.scale_factor) except StandardError, e: err_msg = traceback.format_exc() dlg = gtk.Dialog("Textext Error", self._window, gtk.DIALOG_MODAL) dlg.set_default_size(600, 400) btn = dlg.add_button(gtk.STOCK_OK, gtk.RESPONSE_CLOSE) btn.connect("clicked", lambda w, d=None: dlg.destroy()) msg = gtk.Label() msg.set_markup("<b>Error occurred while converting text from Latex to SVG:</b>") txtw = gtk.ScrolledWindow() txtw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) txtw.set_shadow_type(gtk.SHADOW_IN) txt = gtk.TextView() txt.set_editable(False) txt.get_buffer().set_text(err_msg) txtw.add(txt) dlg.vbox.pack_start(msg, expand=False, fill=True) dlg.vbox.pack_start(txtw, expand=True, fill=True) dlg.show_all() dlg.run() return False gtk.main_quit() return False
def do_columns(self): eset = self.get_current_editorset() driver = directory.get_driver(eset.rthread.radio.__class__) radio_name = "%s %s %s" % (eset.rthread.radio.VENDOR, eset.rthread.radio.MODEL, eset.rthread.radio.VARIANT) d = gtk.Dialog(title=_("Select Columns"), parent=self, buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) vbox = gtk.VBox() vbox.show() sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) sw.add_with_viewport(vbox) sw.show() d.vbox.pack_start(sw, 1, 1, 1) d.set_size_request(-1, 300) d.set_resizable(False) labelstr = _("Visible columns for {radio}").format(radio=radio_name) label = gtk.Label(labelstr) label.show() vbox.pack_start(label) fields = [] memedit = eset.get_current_editor() # .editors["memedit"] unsupported = memedit.get_unsupported_columns() for colspec in memedit.cols: if colspec[0].startswith("_"): continue elif colspec[0] in unsupported: continue label = colspec[0] visible = memedit.get_column_visible(memedit.col(label)) widget = gtk.CheckButton(label) widget.set_active(visible) fields.append(widget) vbox.pack_start(widget, 1, 1, 1) widget.show() res = d.run() selected_columns = [] if res == gtk.RESPONSE_OK: for widget in fields: colnum = memedit.col(widget.get_label()) memedit.set_column_visible(colnum, widget.get_active()) if widget.get_active(): selected_columns.append(widget.get_label()) d.destroy() CONF.set(driver, ",".join(selected_columns), "memedit_columns")
def __init__(self, src_radio, dst_radio, parent=None): gtk.Dialog.__init__(self, buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL), title=self.TITLE, parent=parent) self.col_import = 0 self.col_nloc = 1 self.col_oloc = 2 self.col_name = 3 self.col_freq = 4 self.col_comm = 5 self.col_okay = 6 self.col_tmsg = 7 self.caps = { self.col_import: self.ACTION, self.col_nloc: _("To"), self.col_oloc: _("From"), self.col_name: _("Name"), self.col_freq: _("Frequency"), self.col_comm: _("Comment"), } self.tips = { self.col_nloc: _("Location memory will be imported into"), self.col_oloc: _("Location of memory in the file being imported"), } self.types = { self.col_import: gobject.TYPE_BOOLEAN, self.col_oloc: gobject.TYPE_INT, self.col_nloc: gobject.TYPE_INT, self.col_name: gobject.TYPE_STRING, self.col_freq: gobject.TYPE_STRING, self.col_comm: gobject.TYPE_STRING, self.col_okay: gobject.TYPE_BOOLEAN, self.col_tmsg: gobject.TYPE_STRING, } self.src_radio = src_radio self.dst_radio = dst_radio self.used_list = [] self.not_used_list = [] self.build_ui() self.set_default_size(600, 400) self.ww = WaitWindow(_("Preparing memory list..."), parent=parent) self.ww.show() self.ww.grind() self.populate_list() self.ww.hide()
def run(self): r = gtk.Dialog.run(self) if r != gtk.RESPONSE_OK: return None vendor = self.__vend.get_active_text() model = self.__modl.get_active_text() cs = CloneSettings() cs.port = self.__port.get_active_text() if model == _("Detect"): try: cs.radio_class = detect.DETECT_FUNCTIONS[vendor](cs.port) if not cs.radio_class: raise Exception( _("Unable to detect radio on {port}").format( port=cs.port)) except Exception, e: d = inputdialog.ExceptionDialog(e) d.run() d.destroy() return None else: for rclass in directory.DRV_TO_RADIO.values(): if rclass.MODEL == model: cs.radio_class = rclass break alias_match = None for alias in rclass.ALIASES: if alias.MODEL == model: alias_match = rclass break if alias_match: cs.radio_class = rclass LOG.debug( 'Chose %s alias for %s because model %s selected' % ( alias_match, cs.radio_class, model)) break if not cs.radio_class: common.show_error( _("Internal error: Unable to upload to {model}").format( model=model)) LOG.info(self.__vendors) return None conf = config.get("state") conf.set("last_port", cs.port) conf.set("last_vendor", cs.radio_class.VENDOR) conf.set("last_model", model) return cs
def show_diff_blob(title, result): d = gtk.Dialog(title=title, buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK)) b = gtk.TextBuffer() tags = b.get_tag_table() for color in ["red", "blue", "green", "grey"]: tag = gtk.TextTag(color) tag.set_property("foreground", color) tags.add(tag) tag = gtk.TextTag("bold") tag.set_property("weight", pango.WEIGHT_BOLD) tags.add(tag) try: fontsize = CONF.get_int("diff_fontsize", "developer") except Exception: fontsize = 11 if fontsize < 4 or fontsize > 144: LOG.info("Unsupported diff_fontsize %i. Using 11." % fontsize) fontsize = 11 lines = result.split(os.linesep) for line in lines: if line.startswith("-"): tags = ("red", "bold") elif line.startswith("+"): tags = ("blue", "bold") else: tags = () b.insert_with_tags_by_name(b.get_end_iter(), line + os.linesep, *tags) v = gtk.TextView(b) fontdesc = pango.FontDescription("Courier %i" % fontsize) v.modify_font(fontdesc) v.set_editable(False) v.show() s = gtk.ScrolledWindow() s.add(v) s.show() d.vbox.pack_start(s, 1, 1, 1) d.set_size_request(600, 400) d.run() d.destroy()