def __init__(self): super(PostStationDialog, self).__init__() title_label = Gtk.Label() title_label.set_markup("<span font='20.0'>" + _("Post new station") + "</span>") self.get_content_area().pack_start(title_label) self.add_button(Gtk.STOCK_CANCEL, Gtk.RESPONSE_CANCEL) self.add_button(Gtk.STOCK_OK, Gtk.RESPONSE_OK) table = Gtk.Table(3, 8) table.attach(Gtk.Label(_("Examples")), 2, 3, 0, 1) table.attach(Gtk.Label(_("Name")), 0, 1, 1, 2) self.StationName = Gtk.Entry() table.attach(self.StationName, 1, 2, 1, 2) table.attach(Gtk.Label(_("My Station")), 2, 3, 1, 2) table.attach(Gtk.Label(_("URL")), 0, 1, 2, 3) self.StationUrl = Gtk.Entry() table.attach(self.StationUrl, 1, 2, 2, 3) table.attach(Gtk.Label(_("http://listen.to.my/station.pls")), 2, 3, 2, 3) table.attach(Gtk.Label(_("Homepage URL")), 0, 1, 3, 4) self.StationHomepage = Gtk.Entry() table.attach(self.StationHomepage, 1, 2, 3, 4) table.attach(Gtk.Label(_("http://very.cool.site")), 2, 3, 3, 4) table.attach(Gtk.Label(_("Favicon URL")), 0, 1, 4, 5) self.StationFavicon = Gtk.Entry() table.attach(self.StationFavicon, 1, 2, 4, 5) table.attach(Gtk.Label(_("http://very.cool.site/favicon.ico")), 2, 3, 4, 5) table.attach(Gtk.Label(_("Country")), 0, 1, 5, 6) self.StationCountry = Gtk.ComboBoxEntry() table.attach(self.StationCountry, 1, 2, 5, 6) table.attach(Gtk.Label(_("Utopia")), 2, 3, 5, 6) table.attach(Gtk.Label(_("Language")), 0, 1, 6, 7) self.StationLanguage = Gtk.ComboBoxEntry() table.attach(self.StationLanguage, 1, 2, 6, 7) table.attach(Gtk.Label(_("Esperanto")), 2, 3, 6, 7) table.attach(Gtk.Label(_("Tags")), 0, 1, 7, 8) self.StationTags = Gtk.Entry() table.attach(self.StationTags, 1, 2, 7, 8) table.attach(Gtk.Label(_("Classical Jazz Talk")), 2, 3, 7, 8) self.get_content_area().pack_start(table, False) self.set_title(_("Post new station")) self.set_resizable(False) self.set_position(Gtk.WIN_POS_CENTER) self.show_all()
def __init__(self, container, git, changed_callback=None): self.git = git self.changed_callback = changed_callback self.vbox = gtk.VBox(False, 4) tmp_branches = [] active = 0 index = 0 for item in self.git.branch_list(): tmp_branches.append(item.name) if self.git.is_tracking(item.name): active = index index += 1 self.branch_opt = ComboBox(gtk.ComboBoxEntry(), tmp_branches) self.branch_opt.set_active(active) self.branch_opt.cb.connect("changed", self.__branch_changed) self.branch_opt.cb.set_size_request(175, -1) hbox = gtk.HBox(False, 0) hbox.pack_start(self.branch_opt.cb, False, False, 0) self.vbox.pack_start(hbox, False, False, 0) self.vbox.show_all() container.add(self.vbox)
def setup_edit_widget(self): '''Return an edit widget to let users edit your data. ''' self.cb = cb = Gtk.ComboBoxEntry() cb.set_model(self.shopcat_model) cb.set_text_column(0) entry = cb.get_child() completion = Gtk.EntryCompletion() completion.set_model(self.shopcat_model) completion.set_text_column(0) entry.set_completion(completion) return cb
cell = Gtk.CellRendererText() # help(cb) # | pack_start(self, cell:Gtk.CellRenderer, expand:bool) cb.pack_start(cell, expand) cb.add_attribute(cell, 'text',0) setup_typeahead(cb, 0) if __name__ == '__main__': w = Gtk.Window() vb = Gtk.VBox() #vb.add(Gtk.Button('Blank button')) #for n in range(10): vb.add(Gtk.Button('Other blank')) hbox = Gtk.HBox() label = Gtk.Label() label.set_text_with_mnemonic('Enter a _fruit: ') cbe = Gtk.ComboBoxEntry() FocusFixer(cbe) label.set_mnemonic_widget(cbe) set_model_from_list(cbe, ['Apples','Oranges','Grapes','Mango', 'Papaya','Plantain','Kiwi','Cherry', 'Bananas']) hbox.add(label) hbox.add(cbe) vb.add(Gtk.Label(label="""Here's an EntryCompletion widget automatically in sync with the ComboBoxEntry widget. Hitting return will select the first item in the EntryCompletion popup window.""")) vb.add(hbox) def make_combo (expand=True): label2 = Gtk.Label() label2.set_text_with_mnemonic('Mode of _Transportation') cb = Gtk.ComboBox()
def __init__(self, container, git, changed_callback=None): self.git = git self.changed_callback = changed_callback vbox = gtk.VBox(False, 4) # Set up the Repository Line label = gtk.Label(_("Repository:")) label.set_size_request(90, -1) label.set_justify(gtk.JUSTIFY_LEFT) tmp_repos = [] for item in self.git.remote_list(): tmp_repos.append(item["name"]) self.repository_opt = ComboBox(gtk.ComboBoxEntry(), tmp_repos) self.repository_opt.set_active(0) self.repository_opt.cb.connect("changed", self.__repository_changed) self.repository_opt.cb.set_size_request(175, -1) hbox = gtk.HBox(False, 0) hbox.pack_start(label, False, False, 0) hbox.pack_start(self.repository_opt.cb, False, False, 0) vbox.pack_start(hbox, False, False, 0) # Set up the Branch line label = gtk.Label(_("Branch:")) label.set_size_request(90, -1) label.set_justify(gtk.JUSTIFY_LEFT) tmp_branches = [] active_branch_index = 0 index = 0 for item in self.git.branch_list(): tmp_branches.append(item.name) if item.tracking: active_branch_index = index index += 1 self.branch_opt = ComboBox(gtk.ComboBoxEntry(), tmp_branches) self.branch_opt.set_active(active_branch_index) self.branch_opt.cb.connect("changed", self.__branch_changed) self.branch_opt.cb.set_size_request(175, -1) hbox = gtk.HBox(False, 0) hbox.pack_start(label, False, False, 0) hbox.pack_start(self.branch_opt.cb, False, False, 0) vbox.pack_start(hbox, False, False, 0) # Set up the Host line label = gtk.Label(_("Host:")) label.set_justify(gtk.JUSTIFY_LEFT) label.set_size_request(90, -1) self.host = gtk.Label() self.host.set_justify(gtk.JUSTIFY_LEFT) hbox = gtk.HBox(False, 0) hbox.pack_start(label, False, False, 0) hbox.pack_start(self.host, False, False, 0) vbox.pack_start(hbox, False, False, 4) vbox.show_all() container.add(vbox) self.__update_host()
def combo_box_entry_new_with_model(model): return Gtk.ComboBoxEntry(model=model)
def combo_box_entry_new(): return Gtk.ComboBoxEntry()
def __init__(self, has_pyew, has_radare, core='', file='', first_run=False): super(FileDialog, self).__init__( 'Select file', None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) self.has_pyew = has_pyew self.has_radare = has_radare self.core = core self.file = file self.timer_id = None # Set dialog resizeable and auto-shrink self.set_policy(False, False, True) self.set_icon_from_file( os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'bokken.svg') # the cancel button self.butt_ok = self.action_area.get_children()[0] self.butt_ok.connect("clicked", self.fast_start) self.butt_cancel = self.action_area.get_children()[1] #self.butt_cancel.connect("clicked", self.cancel) # Window position self.set_position(Gtk.WindowPosition.CENTER) # Main Vertical Box self.main_vbox = Gtk.VBox(False, 2) self.main_vbox.set_border_width(7) # Logo self.logo = Gtk.Image() self.logo.set_from_file( os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'bokken.svg') # Logo label self.logo_text = Gtk.Label() self.logo_text.set_markup( '<span size=\'12000\'>Welcome to <b>Bokken 1.5</b></span>') # Common label self.label = Gtk.Label( label='Select a target or enter the path manually.') self.label.set_padding(0, 3) self.label.set_alignment(0, 0.5) # Pyew targets label self.pyew_label = Gtk.Label() self.pyew_label.set_markup( 'Valid inputs are: <b>PE/ELF, PDF, plain text files and URLs</b>') self.pyew_label.set_padding(0, 2) # Radare targets label self.radare_label = Gtk.Label() self.radare_label.set_markup( 'Valid inputs are: <b>PE, ELF, mach0 and java/dex classes</b>') self.radare_label.set_padding(0, 2) # Horizontal Separator self.hseparator1 = Gtk.HSeparator() # Core selection label and combo self.core_label = Gtk.Label(label='Select backend to use: ') self.core_label.set_alignment(0, 0.5) self.core_combo = Gtk.ComboBoxText() if self.has_pyew: self.core_combo.append_text('Pyew') if self.has_radare: self.core_combo.append_text('Radare') if not self.core: self.core_combo.set_active(0) elif self.has_radare != self.has_pyew: self.core_combo.set_active(0) elif self.core == 'pyew': self.core_combo.set_active(0) if not first_run: self.core_combo.remove_text(1) elif self.core == 'radare': self.core_combo.set_active(1) if not first_run: self.core_combo.remove_text(0) self.core = self.core_combo.get_active_text().lower() # Core combo Horizontal Box self.core_hbox = Gtk.HBox(False, 0) self.core_hbox.pack_start(self.core_label, True, True, 2) self.core_hbox.pack_start(self.core_combo, False, False, 2) # Horizontal Separator self.hseparator2 = Gtk.HSeparator() # File selection Horizontal Box self.hbox = Gtk.HBox(False, 0) # TextEntry self.model = Gtk.ListStore(str) self.input_entry = Gtk.ComboBoxEntry(self.model, column=0) self.input_entry.get_child().connect("activate", self.fast_start) self.input_entry.connect("changed", self._validate_cb) #self.input_entry = Gtk.Entry(100) if self.file: self.input_entry.get_child().set_text(self.file) # Recent file manager self.manager = Gtk.RecentManager.get_default() items = self.manager.get_items() for element in items[:10]: self.model.append([element.get_display_name()]) # Select file button icon = Gtk.Image() icon.set_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.MENU) self.select_button = Gtk.Button() self.select_button.set_image(icon) self.select_button.connect("clicked", self.select_file) # Pack elements into hbox self.hbox.pack_start(self.input_entry, True, True, 2) self.hbox.pack_start(self.select_button, False, False, 2) # File options Horizontal Box self.options_hbox = Gtk.HBox(False, 2) # Pyew option Vertical Box self.pyew_box = Gtk.VBox(False, 0) # Radare option Vertical Box self.radare_box = Gtk.VBox(False, 0) # pack the boxes self.options_hbox.pack_start(self.pyew_box, False, False, 0) self.options_hbox.pack_start(self.radare_box, False, False, 0) # HSeparator self.hseparator3 = Gtk.HSeparator() # Analysis options label self.anal_label = Gtk.Label() self.anal_label.set_markup("<b>Analysis options:</b>") # Pyew options self.deep_anal = Gtk.CheckButton(label='Deep analysis') self.case_dasm = Gtk.CheckButton(label='Lower case disassembly') self.case_dasm.set_active(True) self.pyew_box.pack_start(self.deep_anal, False, False, 2) self.pyew_box.pack_start(self.case_dasm, False, False, 2) # It's here to avoid errors during start up self.core_combo.connect("changed", self._on_change) # Radare options self.anal_bin = Gtk.CheckButton(label='Analyze program') self.anal_bin.set_active(True) self.radare_dasm = Gtk.CheckButton(label='Lower case disassembly') self.radare_dasm.set_active(True) self.io_va = Gtk.CheckButton(label='Don\'t use VA') self.asm_syntax = Gtk.CheckButton(label='Use AT&T syntax') self.asm_bytes = Gtk.CheckButton(label='Don\'t show asm bytes') self.anal_bin.connect("toggled", self._no_anal) self.radare_box.pack_start(self.anal_bin, False, False, 2) self.radare_box.pack_start(self.radare_dasm, False, False, 2) self.radare_box.pack_start(self.io_va, False, False, 2) self.radare_box.pack_start(self.asm_syntax, False, False, 2) self.radare_box.pack_start(self.asm_bytes, False, False, 2) # Pack elements into main_vbox self.main_vbox.pack_start(self.logo, False, False, 0) self.main_vbox.pack_start(self.logo_text, False, False, 0) self.main_vbox.pack_start(self.hseparator1, False, False, 2) self.main_vbox.pack_start(self.core_hbox, False, False, 2) self.main_vbox.pack_start(self.hseparator2, False, False, 2) self.main_vbox.pack_start(self.label, False, False, 2) self.main_vbox.pack_start(self.pyew_label, False, False, 1) self.main_vbox.pack_start(self.radare_label, False, False, 1) self.main_vbox.pack_start(self.hbox, False, False, 2) self.main_vbox.pack_start(self.hseparator3, False, False, 2) self.main_vbox.pack_start(self.anal_label, False, False, 2) self.main_vbox.pack_start(self.options_hbox, False, False, 2) self.vbox.pack_start(self.main_vbox, True, True, 0) self.set_focus(self.input_entry.get_child()) self.show_all() if self.core == 'pyew': self.radare_box.set_visible(False) self.radare_label.set_visible(False) elif self.core == 'radare': self.pyew_box.set_visible(False) self.pyew_label.set_visible(False) else: self.radare_box.set_visible(False) self.radare_label.set_visible(False)
def __init__(self): GObject.GObject.__init__(self, False) # Toolbar # self.listener_tb = Gtk.Toolbar() self.listener_tb.set_style(Gtk.ToolbarStyle.ICONS) # Upload button self.upload_tb = Gtk.ToolButton(Gtk.STOCK_GO_UP) self.upload_tb.set_tooltip_text('Upload file') #self.upload_tb.connect("clicked", self.load_editor) self.listener_tb.insert(self.upload_tb, 0) # Download button self.download_tb = Gtk.ToolButton(Gtk.STOCK_GO_DOWN) self.download_tb.set_tooltip_text('Download file') #self.upload_tb.connect("clicked", self.load_editor) self.listener_tb.insert(self.download_tb, 1) # Directory list button self.dirlist_tb = Gtk.ToolButton(Gtk.STOCK_DIRECTORY) self.dirlist_tb.set_tooltip_text('List directories') #self.upload_tb.connect("clicked", self.load_editor) self.listener_tb.insert(self.dirlist_tb, 2) # Separator self.sep = Gtk.SeparatorToolItem() self.listener_tb.insert(self.sep, 3) # Connect self.connect_tb = Gtk.ToolButton(Gtk.STOCK_CONNECT) self.connect_tb.set_tooltip_text('Connect to target') #self.upload_tb.connect("clicked", self.load_editor) self.listener_tb.insert(self.connect_tb, 4) # Disconnect self.disconnect_tb = Gtk.ToolButton(Gtk.STOCK_DISCONNECT) self.disconnect_tb.set_tooltip_text('Disconnect to target') #self.upload_tb.disconnect("clicked", self.load_editor) self.listener_tb.insert(self.disconnect_tb, 5) # Separator self.sep = Gtk.SeparatorToolItem() self.listener_tb.insert(self.sep, 6) # Post-exploit label self.post_label_tb = Gtk.ToolItem() self.post_label_align = Gtk.Alignment.new(yalign=0.5) self.post_label = Gtk.Label(label='Post exploitation commands:\t') self.post_label_align.add(self.post_label) self.post_label_tb.add(self.post_label_align) self.listener_tb.insert(self.post_label_tb, 7) # Search components self.postxpl_combo_tb = Gtk.ToolItem() self.postxpl_combo_align = Gtk.Alignment.new(yalign=0.5) store = Gtk.ListStore(GdkPixbuf.Pixbuf, str) self.postxpl_combo = Gtk.ComboBox(store) rendererText = Gtk.CellRendererText() rendererPix = Gtk.CellRendererPixbuf() self.postxpl_combo.pack_start(rendererPix, False) self.postxpl_combo.pack_start(rendererText, True) self.postxpl_combo.add_attribute(rendererPix, 'pixbuf', 0) self.postxpl_combo.add_attribute(rendererText, 'text', 1) options = { 'Windows': GdkPixbuf.Pixbuf.new_from_file( os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'icons' + os.sep + 'windows.png'), 'Linux': GdkPixbuf.Pixbuf.new_from_file( os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'icons' + os.sep + 'linux.png'), 'MacOS': GdkPixbuf.Pixbuf.new_from_file( os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'icons' + os.sep + 'apple.png'), } for option in list(options.keys()): store.append([options[option], option]) self.postxpl_combo.set_active(0) self.postxpl_combo_align.add(self.postxpl_combo) self.postxpl_combo_tb.add(self.postxpl_combo_align) self.listener_tb.insert(self.postxpl_combo_tb, 8) # Separator self.sep = Gtk.SeparatorToolItem() self.sep.set_draw(False) self.listener_tb.insert(self.sep, 9) # Combobox Entry for command selection and edit self.comm_combo_tb = Gtk.ToolItem() self.comm_combo_align = Gtk.Alignment.new(yalign=0.5) self.comm_store = Gtk.ListStore(GObject.TYPE_STRING) self.comm_combo = Gtk.ComboBoxEntry(self.comm_store, 0) self.comm_combo_entry = self.comm_combo.get_child() self.comm_combo_entry.set_icon_from_stock(1, Gtk.STOCK_EXECUTE) #self.comm_store.append(['netstat -an']) self.comm_combo_align.add(self.comm_combo) self.comm_combo_tb.add(self.comm_combo_align) self.listener_tb.insert(self.comm_combo_tb, 10) # Separator self.sep = Gtk.SeparatorToolItem() self.sep.set_expand(True) self.sep.set_draw(False) self.listener_tb.insert(self.sep, 11) # Throbber self.throbber = throbber.Throbber() self.throbber_tb = Gtk.ToolItem() self.throbber_tb.add(self.throbber) self.listener_tb.insert(self.throbber_tb, 12) self.pack_start(self.listener_tb, False, False, 0) # Textview # self.listener_tv = Gtk.TextView(buffer=None) # Some eye candy self.listener_tv.modify_base(Gtk.StateType.NORMAL, Gdk.Color(16400, 16400, 16440)) self.listener_tv.modify_text(Gtk.StateType.NORMAL, Gdk.Color(60535, 60535, 60535, 0)) self.listener_tv.set_left_margin(10) self.listener_tv.set_wrap_mode(Gtk.WrapMode.NONE) self.listener_tv.set_editable(False) self.textbuffer = self.listener_tv.get_buffer() self.textbuffer.set_text('C:\\WINNT\\system32>\n') self.listener_tv.show() # Scrolled Window # self.listener_sw = Gtk.ScrolledWindow() self.listener_sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.listener_sw.is_visible = True #Always on bottom on change self.vajd = self.listener_sw.get_vadjustment() self.vajd.connect('changed', lambda a, s=self.listener_sw: self.rescroll(a, s)) # Add Textview to Scrolled Window self.listener_sw.add_with_viewport(self.listener_tv) self.pack_start(self.listener_sw, True, True, 0) # Commands Entry self.comm_entry = Gtk.Entry() self.comm_entry.set_icon_from_stock(1, Gtk.STOCK_EXECUTE) self.comm_entry.set_icon_from_stock(0, Gtk.STOCK_CLEAR) self.comm_entry.modify_base(Gtk.StateType.NORMAL, Gdk.Color(16400, 16400, 16440)) self.comm_entry.modify_text(Gtk.StateType.NORMAL, Gdk.Color(60535, 60535, 60535, 0)) self.pack_start(self.comm_entry, False, False, 0) self.show_all()