示例#1
0
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title(_("Nanotube"))
        vbox = gtk.VBox()

        # Intoductory text
        self.packtext(vbox, introtext)

        # Choose the element and bond length
        label1 = gtk.Label(_("Element: "))
        #label.set_alignment(0.0, 0.2)
        self.element = gtk.Entry(max=3)
        self.element.set_text("C")
        self.element.connect('activate', self.makeatoms)
        self.bondlength = gtk.Adjustment(1.42, 0.0, 1000.0, 0.01)
        label2 = gtk.Label(_("  Bond length: "))
        label3 = gtk.Label(_(u"Å"))
        bond_box = gtk.SpinButton(self.bondlength, 10.0, 3)
        pack(vbox, [label1, self.element, label2, bond_box, label3])
        self.elementinfo = gtk.Label("")
        self.elementinfo.modify_fg(gtk.STATE_NORMAL,
                                   gtk.gdk.color_parse('#FF0000'))
        pack(vbox, [self.elementinfo])
        pack(vbox, gtk.Label(""))

        # Choose the structure.
        pack(vbox,
             [gtk.Label(_("Select roll-up vector (n,m) "
                          "and tube length:"))])
        label1 = gtk.Label("n: ")
        label2 = gtk.Label("  m: ")
        self.n = gtk.Adjustment(5, 1, 100, 1)
        self.m = gtk.Adjustment(5, 0, 100, 1)
        spinn = gtk.SpinButton(self.n, 0, 0)
        spinm = gtk.SpinButton(self.m, 0, 0)
        label3 = gtk.Label(_("  Length: "))
        self.length = gtk.Adjustment(1, 1, 100, 1)
        spinl = gtk.SpinButton(self.length, 0, 0)
        pack(vbox, [label1, spinn, label2, spinm, label3, spinl])
        self.err = gtk.Label("")
        self.err.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FF0000'))
        pack(vbox, [self.err])
        pack(vbox, gtk.Label(""))

        self.status = gtk.Label("")
        pack(vbox, [self.status])
        pack(vbox, [gtk.Label("")])

        # Buttons
        self.pybut = PyButton(_("Creating a nanoparticle."))
        self.pybut.connect('clicked', self.makeatoms)
        buts = cancel_apply_ok(cancel=lambda widget: self.destroy(),
                               apply=self.apply,
                               ok=self.ok)
        pack(vbox, [self.pybut, buts], end=True, bottom=True)

        # Finalize setup
        self.makeatoms()
        self.bondlength.connect('value-changed', self.makeatoms)
        self.m.connect('value-changed', self.makeatoms)
        self.n.connect('value-changed', self.makeatoms)
        self.length.connect('value-changed', self.makeatoms)
        self.add(vbox)
        vbox.show()
        self.show()
        self.gui = gui
示例#2
0
 def do_circle(self, fWizard, tmpDir):
     self.tmpDir = tmpDir
     self.fWizard = fWizard
     self.sRadius = 0.0
     self.hSpeed = 100
     self.W = gtk.Dialog('Circle',
                         None,
                         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                         buttons=None)
     self.W.set_keep_above(True)
     self.W.set_position(gtk.WIN_POS_CENTER_ALWAYS)
     self.W.set_default_size(250, 200)
     t = gtk.Table(1, 1, True)
     t.set_row_spacings(6)
     self.W.vbox.add(t)
     cutLabel = gtk.Label('Cut Type')
     cutLabel.set_alignment(0.95, 0.5)
     cutLabel.set_width_chars(10)
     t.attach(cutLabel, 0, 1, 0, 1)
     self.outside = gtk.RadioButton(None, 'Outside')
     self.outside.connect('toggled', self.outside_toggled)
     t.attach(self.outside, 1, 2, 0, 1)
     inside = gtk.RadioButton(self.outside, 'Inside')
     t.attach(inside, 2, 3, 0, 1)
     offsetLabel = gtk.Label('Offset')
     offsetLabel.set_alignment(0.95, 0.5)
     offsetLabel.set_width_chars(10)
     t.attach(offsetLabel, 3, 4, 0, 1)
     self.offset = gtk.CheckButton('Kerf Width')
     t.attach(self.offset, 4, 5, 0, 1)
     lLabel = gtk.Label('Lead In')
     lLabel.set_alignment(0.95, 0.5)
     lLabel.set_width_chars(10)
     t.attach(lLabel, 0, 1, 1, 2)
     self.liEntry = gtk.Entry()
     self.liEntry.set_width_chars(10)
     t.attach(self.liEntry, 1, 2, 1, 2)
     loLabel = gtk.Label('Lead Out')
     loLabel.set_alignment(0.95, 0.5)
     loLabel.set_width_chars(10)
     t.attach(loLabel, 0, 1, 2, 3)
     self.loEntry = gtk.Entry()
     self.loEntry.set_width_chars(10)
     t.attach(self.loEntry, 1, 2, 2, 3)
     xSLabel = gtk.Label('X start')
     xSLabel.set_alignment(0.95, 0.5)
     xSLabel.set_width_chars(10)
     t.attach(xSLabel, 0, 1, 3, 4)
     self.xSEntry = gtk.Entry()
     self.xSEntry.set_width_chars(10)
     t.attach(self.xSEntry, 1, 2, 3, 4)
     ySLabel = gtk.Label('Y start')
     ySLabel.set_alignment(0.95, 0.5)
     ySLabel.set_width_chars(10)
     t.attach(ySLabel, 0, 1, 4, 5)
     self.ySEntry = gtk.Entry()
     self.ySEntry.set_width_chars(10)
     t.attach(self.ySEntry, 1, 2, 4, 5)
     self.centre = gtk.RadioButton(None, 'Centre')
     t.attach(self.centre, 1, 2, 5, 6)
     self.bLeft = gtk.RadioButton(self.centre, 'Bottom Left')
     t.attach(self.bLeft, 0, 1, 5, 6)
     dLabel = gtk.Label('Diameter')
     dLabel.set_alignment(0.95, 0.5)
     dLabel.set_width_chars(10)
     t.attach(dLabel, 0, 1, 6, 7)
     self.dEntry = gtk.Entry()
     self.dEntry.set_width_chars(10)
     self.dEntry.connect('changed', self.diameter_changed)
     t.attach(self.dEntry, 1, 2, 6, 7)
     ocDesc = gtk.Label('Over Cut')
     ocDesc.set_alignment(0.95, 0.5)
     ocDesc.set_width_chars(10)
     t.attach(ocDesc, 0, 1, 7, 8)
     self.overcut = gtk.CheckButton('')
     self.overcut.connect('toggled', self.overcut_toggled)
     self.overcut.set_sensitive(False)
     t.attach(self.overcut, 1, 2, 7, 8)
     ocLabel = gtk.Label('OC Length')
     ocLabel.set_alignment(0.95, 0.5)
     ocLabel.set_width_chars(10)
     t.attach(ocLabel, 0, 1, 8, 9)
     self.ocEntry = gtk.Entry()
     self.ocEntry.set_width_chars(10)
     self.ocEntry.set_sensitive(False)
     self.ocEntry.connect('changed', self.ocentry_changed)
     t.attach(self.ocEntry, 1, 2, 8, 9)
     preview = gtk.Button('Preview')
     preview.connect('pressed', self.send_preview)
     t.attach(preview, 0, 1, 9, 10)
     self.add = gtk.Button('Add')
     self.add.set_sensitive(False)
     self.add.connect('pressed', self.add_shape_to_file)
     t.attach(self.add, 2, 3, 9, 10)
     end = gtk.Button('Return')
     end.connect('pressed', self.end_this_shape)
     t.attach(end, 4, 5, 9, 10)
     pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
         filename='./wizards/images/circle.png', width=240, height=240)
     image = gtk.Image()
     image.set_from_pixbuf(pixbuf)
     t.attach(image, 2, 5, 1, 9)
     self.xSEntry.grab_focus()
     self.W.show_all()
     if os.path.exists(self.configFile):
         f_in = open(self.configFile, 'r')
         for line in f_in:
             if line.startswith('preamble'):
                 self.preamble = line.strip().split('=')[1]
             elif line.startswith('postamble'):
                 self.postamble = line.strip().split('=')[1]
             elif line.startswith('origin'):
                 if line.strip().split('=')[1] == 'True':
                     self.centre.set_active(1)
                 else:
                     self.bLeft.set_active(1)
             elif line.startswith('lead-in'):
                 self.liEntry.set_text(line.strip().split('=')[1])
             elif line.startswith('lead-out'):
                 self.loEntry.set_text(line.strip().split('=')[1])
             elif line.startswith('hole-diameter'):
                 self.sRadius = float(line.strip().split('=')[1]) / 2
             elif line.startswith('hole-speed'):
                 self.hSpeed = float(line.strip().split('=')[1])
     response = self.W.run()
示例#3
0
    def __init__(self, folder):
        '''
        Конструктор
        :param folder: Папка, в которой будет осуществляться поиск
        :type folder: string
        '''
        gtk.gdk.threads_init()
        if os.path.exists(folder):
            self.folder = folder
            
        gtk.Window.__init__(self)
        
        self.set_title(_('File search'))
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_default_size(800,500)
        vbox = gtk.VBox(False, 10)
        
        #main params
        mainParamsVBox = gtk.VBox(False,10)

        hbox1 = gtk.HBox(False,0)
        self.label1 = gtk.Label(_('File name'))
        self.label1.set_alignment(0,0.5)
        self.fileNameEntry = gtk.Entry()
        self.exactCB = gtk.CheckButton(_('Exact'))
        self.caseCB = gtk.CheckButton(_('Case sensitive'))
        self.regexCB = gtk.CheckButton(_('Regex'))
        self.fileTypeCombo = gtk.combo_box_new_text()
        self.fileTypeCombo.append_text(_('Files and folders'))
        self.fileTypeCombo.append_text(_('Files only'))
        self.fileTypeCombo.append_text(_('Folders only'))
        self.fileTypeCombo.set_active(0)
        hbox1.pack_start(self.label1, False, False, 10)
        hbox1.pack_start(self.fileNameEntry, True, True)
        hbox1.pack_start(self.fileTypeCombo, False, False,10)
        hbox1.pack_start(self.exactCB, False, False,10)
        hbox1.pack_start(self.caseCB, False, False,10)
        hbox1.pack_start(self.regexCB, False, False,10)
        
        self.regexCB.connect('clicked',self.regexCBClick)

        hbox2 = gtk.HBox(False,0)
        self.label2 = gtk.Label(_('Search in folder'))
        self.label2.set_alignment(0,0.5)
        self.fileChooser = gtk.FileChooserButton(_('Select folder'))
        self.fileChooser.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        if self.folder:
            self.fileChooser.set_current_folder(self.folder)
        self.folderRecursiveCB = gtk.CheckButton(_('Recursive'))
        self.folderRecursiveCB.set_active(True)
        hbox2.pack_start(self.label2, False, False, 10)
        hbox2.pack_start(self.fileChooser, True, True)
        hbox2.pack_start(self.folderRecursiveCB, False, False, 10)

        hbox3 = gtk.HBox(False,0)
        self.label3 = gtk.Label(_('Search for text'))
        self.label3.set_alignment(0,0.5)
        self.textEntry = gtk.Entry()
        self.textCaseCB = gtk.CheckButton(_('Case sensitive'))
        self.textRegexCB = gtk.CheckButton(_('Regex'))
        hbox3.pack_start(self.label3, False, False, 10)
        hbox3.pack_start(self.textEntry, True, True)
        hbox3.pack_start(self.textCaseCB, False, False, 10)
        hbox3.pack_start(self.textRegexCB, False, False, 10)

        mainParamsVBox.pack_start(hbox1)
        mainParamsVBox.pack_start(hbox2)
        mainParamsVBox.pack_start(hbox3)

        #additional params
        addParamsExpander = gtk.Expander(_('Additional parameters'))
        addParamsHBox = gtk.HBox()

        addParamsVBox1 = gtk.VBox()
        
        self.useLocateCB = gtk.CheckButton(_('Use UNIX \'locate\' command'))
        self.useLocateCB.set_active(True)
        self.useLocateCB.set_tooltip_text('Possibly slow for text search')        
        self.hiddenCB = gtk.CheckButton(_('Process hidden files and folders'))
        self.linksCB = gtk.CheckButton(_('Follow simlinks'))
        self.linksCB.set_tooltip_text('Attention! Dead locks possible! ') 
        self.linksCB.set_active(True)
        addParamsVBox1.pack_start(self.useLocateCB, False, False)
        addParamsVBox1.pack_start(self.hiddenCB, False, False)
        addParamsVBox1.pack_start(self.linksCB, False, False)
        
        addParamsHBox.pack_start(addParamsVBox1,False, False, 10)

        addParamsExpander.add(addParamsHBox)

        #treeview
        
        self.treeview = gtk.TreeView()
        r = gtk.CellRendererText()
        self.treeview.insert_column_with_attributes(-1, "File name", r, text=0)

        #status box
        self.statusBox = gtk.HBox(False,10)
        self.spinner = gtk.Spinner()
        #self.spinner.set_sensitive(0)

        self.statusLabel = gtk.Label('')
#        statusLabel.set_justify(gtk.JUSTIFY_LEFT)
        self.statusLabel.set_alignment(0,0)
        self.statusLabel.set_width_chars(120)
        self.statusBox.pack_start(self.spinner,False,False,10)
        self.statusBox.pack_start(self.statusLabel, False, False,10)
        
        #button box
        buttonBox = gtk.HButtonBox()
        buttonBox.set_layout(gtk.BUTTONBOX_END)
        buttonBox.set_spacing(10)
        buttonBox.set_border_width(10)
        self.buttonStart = gtk.Button(_('Start search'),gtk.STOCK_FIND)
        self.buttonStop = gtk.Button(_('Stop search'), gtk.STOCK_STOP)
        self.imagePause = gtk.Image()
        self.imagePause.set_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_BUTTON)
        self.imageContinue = gtk.Image()
        self.imageContinue.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_BUTTON)
        self.buttonPause = gtk.ToggleButton(_('Pause search'))
        self.buttonPause.set_image(self.imagePause)
        self.buttonPause.set_mode(True)
        self.buttonClose = gtk.Button(_('Close'), gtk.STOCK_CLOSE)
        buttonBox.add(self.buttonStart)
        buttonBox.add(self.buttonStop)
        buttonBox.add(self.buttonPause)
        buttonBox.add(self.buttonClose)

        self.buttonClose.connect('clicked', self.closeSearch)
        self.buttonStart.connect('clicked', self.startSearch)
        self.buttonStop.connect('clicked', self.stopSearch)
        self.buttonPause.connect('clicked',self.pauseSearch)
        
        self.buttonStop.set_sensitive(0)
        self.buttonPause.set_sensitive(0)        
        
        vbox.pack_start(mainParamsVBox, False, True, 10)
        vbox.pack_start(addParamsExpander, False, True, 0)
        scrolled = gtk.ScrolledWindow()
        scrolled.add(self.treeview)
        vbox.pack_start(scrolled, True, True, 0)
        vbox.pack_start(self.statusBox, False, True, 0)
        vbox.pack_start(buttonBox, False, True, 0)
        self.add(vbox)

        #self.connect('destroy', self.closeSearch)
        self.connect('delete-event', self.closeSearch)
示例#4
0
    def __init__(self):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("New Mirror"))
        self._window.set_modal(True)
        self._window.set_position(gtk.WIN_POS_CENTER)

        #self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True

        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        table = gtk.Table()
        table.set_row_spacings(10)
        table.set_col_spacings(10)
        table.show()
        vbox.pack_start(table)

        label = gtk.Label(_("Origin URL:"))
        label.set_alignment(1.0, 0.5)
        label.show()
        table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL)

        self._origin = gtk.Entry()
        self._origin.set_width_chars(40)
        self._origin.show()
        table.attach(self._origin, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)

        label = gtk.Label(_("Mirror URL:"))
        label.set_alignment(1.0, 0.5)
        label.show()
        table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL)

        self._mirror = gtk.Entry()
        self._mirror.set_width_chars(40)
        self._mirror.show()
        table.attach(self._mirror, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)

        sep = gtk.HSeparator()
        sep.show()
        vbox.pack_start(sep, expand=False)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        self._okbutton = gtk.Button(stock="gtk-ok")
        self._okbutton.show()

        def clicked(x):
            self._result = True
            gtk.main_quit()

        self._okbutton.connect("clicked", clicked)
        bbox.pack_start(self._okbutton)

        self._cancelbutton = gtk.Button(stock="gtk-cancel")
        self._cancelbutton.show()
        self._cancelbutton.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(self._cancelbutton)
示例#5
0
	def __init__(self, controller):
		GLIScreen.GLIScreen.__init__(self, controller)

		self.has_systempkgs = GLIUtility.is_file("/usr/livecd/systempkgs.txt")

		vert = gtk.VBox(False, 0)
		vert.set_border_width(10)

		content_str = """Here, you will select which stage you would like to start your install from.
Each option has a brief description beside it.
"""
		content_label = gtk.Label(content_str)
		vert.pack_start(content_label, expand=False, fill=False, padding=0)            
		self.radio_stages[1] = gtk.RadioButton(None, "Stage 1")
		self.radio_stages[1].set_name("1")
		self.radio_stages[1].connect("toggled", self.stage_selected, "1")
		self.radio_stages[1].set_size_request(100, -1)
		hbox = gtk.HBox(False, 0)
		hbox.pack_start(self.radio_stages[1], expand=False, fill=False, padding=5)
		tmplabel = gtk.Label("The entire system will be compiled from scratch with your CHOST and CFLAGS settings")
		tmplabel.set_line_wrap(True)
		hbox.pack_start(tmplabel, expand=False, fill=False, padding=20)
		vert.pack_start(hbox, expand=False, fill=False, padding=10)
		self.radio_stages[2] = gtk.RadioButton(self.radio_stages[1], "Stage 2")
		self.radio_stages[2].set_name("2")
		self.radio_stages[2].connect("toggled", self.stage_selected, "2")
		self.radio_stages[2].set_size_request(100, -1)
		hbox = gtk.HBox(False, 0)
		hbox.pack_start(self.radio_stages[2], expand=False, fill=False, padding=5)
		tmplabel = gtk.Label("Most of the system will be compiled with your CHOST and CFLAGS settings. Don't use this option unless you have a good reason")
		tmplabel.set_line_wrap(True)
		hbox.pack_start(tmplabel, expand=False, fill=False, padding=20)
		vert.pack_start(hbox, expand=False, fill=False, padding=10)

		self.radio_stages[3] = gtk.RadioButton(self.radio_stages[1], "Stage 3")
		self.radio_stages[3].set_name("3")
		self.radio_stages[3].connect("toggled", self.stage_selected, "3")
		self.radio_stages[3].set_size_request(100, -1)
		hbox = gtk.HBox(False, 0)
		hbox.pack_start(self.radio_stages[3], expand=False, fill=False, padding=5)
		tmplabel = gtk.Label("The base system will be installed using precompiled packages. You can recompile later with your custom settings if you choose. This is the fastest option")
		tmplabel.set_line_wrap(True)
		hbox.pack_start(tmplabel, expand=False, fill=False, padding=20)
		vert.pack_start(hbox, expand=False, fill=False, padding=10)

		self.check_grp = gtk.CheckButton("GRP Install")
		self.check_grp.set_sensitive(False)
		self.check_grp.set_size_request(100, -1)
		hbox = gtk.HBox(False, 0)
		hbox.pack_start(self.check_grp, expand=False, fill=False, padding=5)
		tmplabel = gtk.Label("Any extra packages installed (beyond the stage3) will be installed using binaries from the LiveCD that you are installing from")
		tmplabel.set_line_wrap(True)
		hbox.pack_start(tmplabel, expand=False, fill=False, padding=20)
		vert.pack_start(hbox, expand=False, fill=False, padding=10)

		self.check_dynamic = gtk.CheckButton("Dynamic")
		self.check_dynamic.set_sensitive(False)
		self.check_dynamic.connect("toggled", self.dynamic_checked)
		self.check_dynamic.set_size_request(100, -1)
		if not self.has_systempkgs:
			self.check_dynamic.set_sensitive(False)
		hbox = gtk.HBox(False, 0)
		hbox.pack_start(self.check_dynamic, expand=False, fill=False, padding=5)
		tmplabel = gtk.Label("The stage3 will be generated from the packages on the LiveCD")
		tmplabel.set_line_wrap(True)
		hbox.pack_start(tmplabel, expand=False, fill=False, padding=20)
		vert.pack_start(hbox, expand=False, fill=False, padding=10)

		hbox = gtk.HBox(False, 0)
		hbox.pack_start(gtk.Label("Stage tarball URI:"), expand=False, fill=False, padding=5)
		self.entry_stage_tarball_uri = gtk.Entry()
		self.entry_stage_tarball_uri.set_width_chars(50)
		hbox.pack_start(self.entry_stage_tarball_uri, expand=False, fill=False, padding=10)
		self.browse_uri = gtk.Button(" ... ")
		self.browse_uri.connect("clicked", self.browse_uri_clicked)
		hbox.pack_start(self.browse_uri, expand=False, fill=False, padding=5)
		vert.pack_end(hbox, expand=False, fill=False, padding=0)

		self.add_content(vert)
示例#6
0
    def __init__(self):
        """Create window, callbacks, ..."""
        # create window
        self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.win.set_title("StuStaNet Druckservice")
        self.win.set_border_width(5)
        
        # create central vbox
        self.vbox = gtk.VBox(homogeneous=False, spacing=0)

        # logo
        frm = gtk.Frame()
        logo = gtk.Image()
        logo.set_from_file(LOGO)
        logo.show()
        frm.add(logo)
        frm.show()
        self.vbox.pack_start(frm)

        # ensure proper end of application
        self.win.connect('delete_event', lambda w, e: gtk.main_quit())
        self.win.connect('destroy', self.quit)


        # uploaded files
        frm = gtk.Frame(label=" Hochgeladene Dateien ")
        self.upl_hbox = gtk.HBox(homogeneous=False, spacing=0)
        self.upl_hbox.set_border_width(5)
        lbl = gtk.Label("PIN: ")
        lbl.show()
        self.upl_hbox.pack_start(lbl, fill=False, expand=False)
        self.pin_input = gtk.Entry()
        self.pin_input.show()
        self.upl_hbox.pack_start(self.pin_input)
        self.upl_button = gtk.Button("Laden")
        self.upl_button.connect('clicked', self.load_uploaded, None)
        self.upl_button.show()
        self.upl_hbox.pack_start(self.upl_button, padding=5, fill=False, expand=False)
        self.upl_hbox.show()
        frm.add(self.upl_hbox)
        frm.show()
        self.vbox.pack_start(frm)

        # file chooser button
        frm = gtk.Frame(label=' Dateien von USB-Stick oder Festplatte ')
        hbox = gtk.HBox(homogeneous=False, spacing=0)
        hbox.set_border_width(5)
        self.open_filter = gtk.FileFilter()
        self.open_filter.add_pattern('*.pdf')
        self.open_filter.set_name('PDF Dateien')
        self.chooser_dialog = gtk.FileChooserDialog(
                action=gtk.FILE_CHOOSER_ACTION_OPEN,
                title='Datei drucken',
                buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                    gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)
            )
        self.chooser_dialog.set_local_only(True)
        self.chooser_dialog.set_select_multiple(False)
        self.chooser_dialog.set_filter(self.open_filter)
        self.open_button = gtk.FileChooserButton(self.chooser_dialog)
        self.open_button.set_width_chars(30)
        self.open_button.connect('file-set', self.file_selected, None)
        self.open_button.show()
        lbl = gtk.Label('Datei öffnen: ')
        lbl.show()
        hbox.pack_start(lbl, expand=False, fill=False)
        hbox.pack_start(self.open_button)
        hbox.show()
        frm.add(hbox)
        frm.show()
        self.vbox.pack_start(frm)

        # duplex and b/w checkboxes
        frm = gtk.Frame(" Druckeinstellungen ")
        vbox = gtk.VBox(homogeneous=False, spacing=0)
        self.bw_checkbox = gtk.CheckButton(label="Schwarz / Weiss")
        self.bw_checkbox.show()
        self.simplex_radio = gtk.RadioButton(None, "Einseitig")
        self.simplex_radio.show()
        self.simplex_radio.connect('toggled', self.checkbox_changed, None)
        #self.simplex_radio.set_active(True)
        self.long_edge_radio = gtk.RadioButton(self.simplex_radio, "Doppelseitig (lange Seite)")
        self.long_edge_radio.show()
        self.long_edge_radio.connect('toggled', self.checkbox_changed, None)
        self.short_edge_radio = gtk.RadioButton(self.simplex_radio, "Doppelseitig (kurze Seite)")
        self.short_edge_radio.show()
        self.short_edge_radio.connect('toggled', self.checkbox_changed, None)
        self.bw_checkbox.connect('toggled', self.checkbox_changed, None)
        vbox.pack_start(self.simplex_radio)
        vbox.pack_start(self.long_edge_radio)
        vbox.pack_start(self.short_edge_radio)
        vbox.pack_start(self.bw_checkbox)
        vbox.show()
        frm.add(vbox)
        frm.show()
        self.vbox.pack_start(frm)

        # button
        self.action_button = gtk.Button(
                label="Berechnen"
            )
        self.action_button.child.set_use_markup(True)
        self.action_button.connect('clicked', self.do_action, None)
        self.action_button.show()
        self.vbox.pack_start(self.action_button)

        # add main hbox
        self.win.add(self.vbox)

        self.apply_state()

        # show window
        self.vbox.show()
        self.win.show()
示例#7
0
    def __init__(self, *args, **kwargs):
        gtk.Window.__init__(self, *args, **kwargs)
        self.set_title('Spell check')
        self.set_default_size(350, 200)

        self._checker = None
        self._numContext = 40

        self.errors = None

        # create accel group
        accel_group = gtk.AccelGroup()
        self.add_accel_group(accel_group)

        # list of widgets to disable if there's no spell error left
        self._conditional_widgets = []
        conditional = self._conditional_widgets.append

        # layout
        mainbox = gtk.VBox(spacing=5)
        hbox = gtk.HBox(spacing=5)
        self.add(mainbox)
        mainbox.pack_start(hbox, padding=5)

        box1 = gtk.VBox(spacing=5)
        hbox.pack_start(box1, padding=5)
        conditional(box1)

        # unrecognized word
        text_view_lable = gtk.Label('Unrecognized word')
        text_view_lable.set_justify(gtk.JUSTIFY_LEFT)
        box1.pack_start(text_view_lable, False, False)

        text_view = gtk.TextView()
        text_view.set_wrap_mode(gtk.WRAP_WORD)
        text_view.set_editable(False)
        text_view.set_cursor_visible(False)
        self.error_text = text_view.get_buffer()
        text_buffer = text_view.get_buffer()
        text_buffer.create_tag("fg_black", foreground="black")
        text_buffer.create_tag("fg_red", foreground="red")

        box1.pack_start(text_view)

        # Change to
        change_to_box = gtk.HBox()
        box1.pack_start(change_to_box, False, False)

        change_to_label = gtk.Label('Change to:')
        self.replace_text = gtk.Entry()
        text_view_lable.set_justify(gtk.JUSTIFY_LEFT)
        change_to_box.pack_start(change_to_label, False, False)
        change_to_box.pack_start(self.replace_text)

        # scrolled window
        sw = gtk.ScrolledWindow()
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        box1.pack_start(sw)

        self.suggestion_list_view = create_list_view('Suggestions')
        self.suggestion_list_view.connect("button_press_event",
                                          self._onButtonPress)
        self.suggestion_list_view.connect("cursor-changed",
                                          self._onSuggestionChanged)
        sw.add(self.suggestion_list_view)

        #---Buttons---#000000#FFFFFF----------------------------------------------------
        button_box = gtk.VButtonBox()
        hbox.pack_start(button_box, False, False)

        # Ignore
        button = gtk.Button("Ignore")
        button.connect("clicked", self._onIgnore)
        button.add_accelerator("activate", accel_group, gtk.keysyms.Return, 0,
                               gtk.ACCEL_VISIBLE)
        button_box.pack_start(button)
        conditional(button)

        # Ignore all
        button = gtk.Button("Ignore All")
        button.connect("clicked", self._onIgnoreAll)
        button_box.pack_start(button)
        conditional(button)

        # Replace
        button = gtk.Button("Replace")
        button.connect("clicked", self._onReplace)
        button_box.pack_start(button)
        conditional(button)

        # Replace all
        button = gtk.Button("Replace All")
        button.connect("clicked", self._onReplaceAll)
        button_box.pack_start(button)
        conditional(button)

        # Recheck button
        button = gtk.Button("_Add")
        button.connect("clicked", self._onAdd)

        button_box.pack_start(button)
        conditional(button)

        # Close button
        button = gtk.Button(stock=gtk.STOCK_CLOSE)
        button.connect("clicked", self._onClose)
        button.add_accelerator("activate", accel_group, gtk.keysyms.Escape, 0,
                               gtk.ACCEL_VISIBLE)
        button_box.pack_end(button)

        # dictionary label
        self._dict_lable = gtk.Label('')
        mainbox.pack_start(self._dict_lable, False, False, padding=5)

        mainbox.show_all()
示例#8
0
    sys.path.insert(0, '..')

    import clubBD.database
    import clubBD.model

    clubBD.database.start('../db.db')

    model1 = generic_tree.Model(
        clubBD.database.session.query(clubBD.model.Editor))
    model2 = generic_tree.Model(
        clubBD.database.session.query(clubBD.model.Serial))

    w = gtk.Window()
    b = gtk.VBox()

    e1 = gtk.Entry()
    e2 = gtk.Entry()

    b.add(e1)
    b.add(e2)

    w.add(b)

    def match_func_name(obj, key):
        return obj.name.lower().startswith(key.lower())

    def match_func_title(obj, key):
        return obj.title.lower().startswith(key.lower())

    def display_func_name(obj):
        return obj.name
示例#9
0
        def add_toolbar_button_assistant():
            def cb_close(assistant):
                assi.destroy()
                return False

            def cb_name_entry_key_press(entry, event):
                assi.set_page_complete(entry.get_parent(),
                                       len(entry.get_text()) > 0)

            def cb_func_entry_key_press(entry, event):
                assi.set_page_complete(entry.get_parent(),
                                       len(entry.get_text()) > 0)

            def cb_entry_key_press(entry, event):
                assi.set_page_complete(entry.get_parent(),
                                       len(entry.get_text()) > 0)

            def cb_apply(assistant):
                name_str = name_entry.get_text()
                func_str = func_entry.get_text()
                save_qm = radiobutton_yes.get_active()
                icon_iter = icon_combobox.get_active_iter()
                icon = None
                if (icon_iter):
                    icon, icon_stock, icon_filename = icon_model.get(
                        icon_iter, 0, 1, 2)
                    if (icon_stock):
                        icon = icon_stock

                coot_toolbar_button(name_str, func_str, icon)
                if (save_qm):
                    save_toolbar_to_init_file(name_str, func_str, icon)

            assi = gtk.Assistant()
            assi.set_title("Toolbutton Assistant")

            assi.connect('delete_event', cb_close)
            assi.connect('close', cb_close)
            assi.connect('cancel', cb_close)
            assi.connect('apply', cb_apply)

            # Construct page 0 (enter the button name)
            vbox = gtk.VBox(False, 5)
            vbox.set_border_width(5)
            vbox.show()
            assi.append_page(vbox)
            assi.set_page_title(vbox, 'Create a new Coot toolbutton')
            assi.set_page_type(vbox, gtk.ASSISTANT_PAGE_CONTENT)

            label = gtk.Label(
                "Please enter the name for the new toolbutton...")
            label.set_line_wrap(True)
            label.show()
            vbox.pack_start(label, True, True, 0)

            name_entry = gtk.Entry()
            name_entry.connect("key-press-event", cb_name_entry_key_press)
            name_entry.show()
            vbox.pack_end(name_entry)
            # check if name exists!!!!

            # Construct page 1 (enter the function)
            vbox = gtk.VBox(False, 5)
            vbox.set_border_width(5)
            vbox.show()
            assi.append_page(vbox)
            assi.set_page_title(vbox, 'Set the function')
            assi.set_page_type(vbox, gtk.ASSISTANT_PAGE_CONTENT)

            label = gtk.Label(
                "Please enter the python function... (e.g. refine_active_residue())"
            )
            label.set_line_wrap(True)
            label.show()
            vbox.pack_start(label, True, True, 0)

            func_entry = gtk.Entry()
            func_entry.connect("key-press-event", cb_func_entry_key_press)
            func_entry.show()
            vbox.pack_start(func_entry, True, True, 0)
            # add advanced option? FIXME (for callable func and args!?)
            #adv_button = gtk.Button("Advanced options...")
            #adv_button.show()
            #vbox.pack_start(adv_button, False, False, 0)

            # Construct page 2 (save?)
            vbox = gtk.VBox(False, 5)
            vbox.set_border_width(5)
            vbox.show()
            assi.append_page(vbox)
            assi.set_page_title(vbox, 'Save to preferences?')
            assi.set_page_type(vbox, gtk.ASSISTANT_PAGE_CONTENT)

            label = gtk.Label(
                "Do you want to save the button in your preferences?")
            label.set_line_wrap(True)
            label.show()
            vbox.pack_start(label, True, True, 0)

            radiobutton_yes = gtk.RadioButton(None, "Yes")
            radiobutton_no = gtk.RadioButton(radiobutton_yes, "No")
            radiobutton_yes.set_active(True)
            radiobutton_yes.show()
            radiobutton_no.show()
            vbox.pack_start(radiobutton_yes, True, True, 0)
            vbox.pack_start(radiobutton_no, True, True, 0)
            assi.set_page_complete(radiobutton_yes.get_parent(), True)

            # Construct page 3 (select icon)
            vbox = gtk.VBox(False, 5)
            vbox.set_border_width(5)
            vbox.show()
            assi.append_page(vbox)
            assi.set_page_title(vbox, 'Select an icon')
            assi.set_page_type(vbox, gtk.ASSISTANT_PAGE_CONTENT)

            label = gtk.Label("Please select an icon or leave as it is...")
            label.set_line_wrap(True)
            label.show()
            vbox.pack_start(label, True, True, 0)

            hbox = gtk.HBox(False, 5)
            icon_model = make_icons_model()
            icon_combobox = icon_selection_combobox(icon_model)
            icon_combobox.show()
            hbox.show()
            hbox.pack_start(icon_combobox, True, False, 2)
            vbox.pack_end(hbox)
            assi.set_page_complete(label.get_parent(), True)

            # Final page
            # As this is the last page needs to be of page_type
            # gtk.ASSISTANT_PAGE_CONFIRM or gtk.ASSISTANT_PAGE_SUMMARY
            label = gtk.Label('Thanks for using the toolbutton assistent!')
            label.set_line_wrap(True)
            label.show()
            assi.append_page(label)
            assi.set_page_title(label, 'Finish')
            assi.set_page_complete(label, True)
            assi.set_page_type(label, gtk.ASSISTANT_PAGE_CONFIRM)

            assi.show()
示例#10
0
    def __init__(self, df, si, file_location):
        #Retrieve Dataframe and Size dictionary
        self.df = df
        self.si = si

        self.showSize = 1

        self.menu_items = (
            ("/_File", None, None, 0, "<Branch>"),
            ("/File/_Read HEX Signatures with IDs & Size(.csv)", "<control>O",
             self.read_from_csv, 0, None),
            ("/File/_Read Text Signatures(.txt)", "<control>T",
             self.read_from_text, 0, None),
            ("/File/_Save", "<control>S", self.save_signature, 0, None),
            ("/File/sep1", None, None, 0, "<Separator>"),
            ("/File/Quit", "<control>Q", self.destroy, 0, None),
            ("/_Display", None, None, 0, "<Branch>"),
            ("/Display/_Display Original Text Signatures", "<control>D",
             self.display_original_text, 0, None),
            ("/_Generate", None, None, 0, "<Branch>"),
            ("/Generate/Generate Random Text Signatures", None,
             self.generate_pattern, 0, None),
            ("/_Inject", None, None, 0, "<Branch>"),
            ("/_Inject/Choose a Stream(.txt)", None, self.inject, 0, None),
            ("/_View", None, None, 0, "<Branch>"),
            ("/_View/Stream View", None, self.stream_view, 0, None),
        )

        #Create new GTK Window instance
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("destroy", lambda w: gtk.main_quit())
        self.window.set_title("Signature Utility | File: " +
                              str(file_location))
        self.window.set_default_size(640, 480)

        main_vbox = gtk.VBox(False, 1)
        main_vbox.set_border_width(1)
        #self.window.add(main_vbox)
        main_vbox.show()

        menubar = self.get_main_menu(self.window)

        main_vbox.pack_start(menubar, False, True, 0)
        menubar.show()

        #Create partition for Data display
        dataBox = gtk.VBox(spacing=30)
        frame = gtk.Frame("Pattern Values")

        #Create scrollable display
        scrolledWin = gtk.ScrolledWindow()
        scrolledWin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)

        #Create Table to display values
        self.table = gtk.Table(rows=len(df) + 1, columns=5, homogeneous=False)
        self.table.set_col_spacings(10)
        title_bar = ['ID', 'Size', 'HEX', 'Enable', 'Index']
        for i in range(5):
            label = gtk.Label(title_bar[i])
            label.modify_font(pango.FontDescription("Sans bold 15"))
            self.table.attach(label, i, i + 1, 0, 1)

        #Loop through table to display values
        ctr = 0
        self.button = [None] * 5
        self.entry = [None] * 5
        for i in range(5):
            ctr = 0
            for j in range(1, len(df) + 1):
                if (i < 3):
                    label = gtk.Label(str(df[title_bar[i]][j - 1]))
                    label.modify_font(pango.FontDescription("Sans 10"))
                    #label.set_use_markup(gtk.TRUE)
                    #label.set_markup('<span size="20000">'+str(df[title_bar[i]][j-1])+'</span>')
                    label.set_alignment(0, 0)
                    self.table.attach(label, i, i + 1, j, j + 1)
                elif (i == 3):
                    self.button[ctr] = gtk.CheckButton()
                    self.button[ctr].set_alignment(0, 0)
                    self.table.attach(self.button[ctr], i, i + 1, j, j + 1)
                    ctr = ctr + 1
                else:
                    self.entry[ctr] = gtk.Entry()
                    self.entry[ctr].set_alignment(0)
                    self.entry[ctr].set_width_chars(3)
                    self.table.attach(self.entry[ctr], i, i + 1, j, j + 1)
                    ctr = ctr + 1

        scrolledWin.add_with_viewport(self.table)
        self.table.show()

        frame.add(scrolledWin)
        scrolledWin.show()

        dataBox.pack_start(frame, expand=False, fill=True, padding=5)
        dataBox.set_border_width(1)
        #Create Partition for displaying size information
        sizeBox = gtk.VBox()
        frame = gtk.Frame("Size information")
        sorted_size = sorted(self.si.items(), key=operator.itemgetter(0))

        #Initialize table for size information
        table2 = gtk.Table(rows=len(sorted_size) + 1,
                           columns=2,
                           homogeneous=False)
        table2.attach(gtk.Label("Size"), 0, 1, 0, 1)
        table2.attach(gtk.Label("Count"), 1, 2, 0, 1)

        for i in range(2):
            for j in range(1, len(sorted_size) + 1):
                label = gtk.Label(str(sorted_size[j - 1][i]))
                table2.attach(label, i, i + 1, j, j + 1)
        frame.add(table2)

        sizeBox.pack_start(frame, expand=False, fill=True, padding=0)

        #Arrange all the elements legibly
        self.window.add(main_vbox)
        main_vbox.add(dataBox)
        dataBox.add(sizeBox)
        #sizeBox.add(buttonBox)

        self.window.show_all()

        #Verification utility
        retVal, textVal = verify_size(self.si)
        if (retVal):
            self.message_display("Signatures have the following error(s):\n" +
                                 textVal)
示例#11
0
    def __init__(self, viewertoolbox):
        debug.mainthreadTest()

        toolboxGUI.GfxToolbox.__init__(self, "Viewer", viewertoolbox)
        mainbox = gtk.VBox()
        self.gtk.add(mainbox)

        infoframe = gtk.Frame("Position Information")
        infoframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(infoframe, fill=0, expand=0)

        infotable = gtk.Table(columns=3, rows=2)
        infoframe.add(infotable)
        pixellabel = gtk.Label("Pixel: ")
        pixellabel.set_alignment(1.0, 0.5)
        self.pixel_x = gtk.Entry()
        gtklogger.setWidgetName(self.pixel_x, "PixelX")
        self.pixel_x.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.pixel_x.set_editable(0)
        self.pixel_y = gtk.Entry()
        gtklogger.setWidgetName(self.pixel_y, "PixelY")
        self.pixel_y.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.pixel_y.set_editable(0)
        physicallabel = gtk.Label("Physical: ")
        physicallabel.set_alignment(1.0, 0.5)
        self.physical_x = gtk.Entry()
        gtklogger.setWidgetName(self.physical_x, "PhysicalX")
        self.physical_x.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.physical_x.set_editable(0)
        self.physical_y = gtk.Entry()
        gtklogger.setWidgetName(self.physical_y, "PhysicalY")
        self.physical_y.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.physical_y.set_editable(0)
        infotable.attach(pixellabel,
                         0,
                         1,
                         0,
                         1,
                         xpadding=5,
                         ypadding=2,
                         xoptions=0)
        infotable.attach(self.pixel_x,
                         1,
                         2,
                         0,
                         1,
                         xpadding=1,
                         ypadding=2,
                         xoptions=gtk.FILL | gtk.EXPAND)
        infotable.attach(self.pixel_y,
                         2,
                         3,
                         0,
                         1,
                         xpadding=1,
                         ypadding=2,
                         xoptions=gtk.FILL | gtk.EXPAND)
        infotable.attach(physicallabel,
                         0,
                         1,
                         1,
                         2,
                         xpadding=5,
                         ypadding=2,
                         xoptions=0)
        infotable.attach(self.physical_x,
                         1,
                         2,
                         1,
                         2,
                         xpadding=1,
                         ypadding=2,
                         xoptions=gtk.FILL | gtk.EXPAND)
        infotable.attach(self.physical_y,
                         2,
                         3,
                         1,
                         2,
                         xpadding=1,
                         ypadding=2,
                         xoptions=gtk.FILL | gtk.EXPAND)

        zoomframe = gtk.Frame("Zoom")
        gtklogger.setWidgetName(zoomframe, "Zoom")
        zoomframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(zoomframe, fill=0, expand=0)
        zoombox = gtk.VBox()
        zoomframe.add(zoombox)

        buttonrow = gtk.HBox(homogeneous=1, spacing=2)
        zoombox.pack_start(buttonrow, expand=0, fill=1, padding=2)
        inbutton = gtkutils.StockButton(gtk.STOCK_ZOOM_IN, 'In')
        buttonrow.pack_start(inbutton, expand=0, fill=1)
        gtklogger.setWidgetName(inbutton, "In")
        gtklogger.connect(inbutton, 'clicked', self.inCB)
        outbutton = gtkutils.StockButton(gtk.STOCK_ZOOM_OUT, 'Out')
        buttonrow.pack_start(outbutton, expand=0, fill=1)
        gtklogger.setWidgetName(outbutton, "Out")
        gtklogger.connect(outbutton, 'clicked', self.outCB)
        fillbutton = gtkutils.StockButton(gtk.STOCK_ZOOM_FIT, 'Fill')
        buttonrow.pack_start(fillbutton, expand=0, fill=1)
        gtklogger.setWidgetName(fillbutton, "Fill")
        gtklogger.connect(fillbutton, 'clicked', self.fillCB)

        factorrow = gtk.HBox()
        zoombox.pack_start(factorrow, expand=0, fill=0, padding=2)
        factorrow.pack_start(gtk.Label("Zoom Factor: "), expand=0, fill=0)
        self.zoomfactor = gtk.Entry()
        self.zoomfactor.set_editable(1)
        self.zoomfactor.set_size_request(ndigits * guitop.top().digitsize, -1)
        gtklogger.setWidgetName(self.zoomfactor, "Factor")
        self.zfactorsignal = gtklogger.connect_passive(self.zoomfactor,
                                                       "changed")
        factorrow.pack_start(self.zoomfactor, expand=1, fill=1)

        zoombox.pack_start(gtk.HSeparator(), fill=0, expand=0, padding=2)

        label0 = gtk.Label("Shift+Click: Zoom in\nCtrl+Click: Zoom out")
        label0.set_pattern("             _______\n            ________\n")
        label0.set_justify(gtk.JUSTIFY_LEFT)
        zoombox.pack_start(label0, fill=0, expand=0, padding=2)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_end(align, expand=0, fill=0, padding=2)
        canvas_info = gtkutils.StockButton(gtk.STOCK_DIALOG_INFO,
                                           "Canvas Info")
        gtklogger.setWidgetName(canvas_info, "Info")
        gtklogger.connect(canvas_info, "clicked", self.canvas_infoCB)
        tooltips.set_tooltip_text(
            canvas_info, "Display canvas information in the message window.")
        align.add(canvas_info)

        self.currentZFactor = self.gfxwindow().zoomFactor()

        switchboard.requestCallbackMain("zoom factor changed", self.zfactorCB)

        # Make sure that the Zoom commands in the graphics windows
        # Settings menu use an up-to-date zoom factor.
        self.gfxwindow().menu.Settings.Zoom.In.add_gui_callback(
            self.wrapMenuZoom)
        self.gfxwindow().menu.Settings.Zoom.Out.add_gui_callback(
            self.wrapMenuZoom)
示例#12
0
    def on_menuitem_activate(self, widget, email):
        self.window = gtk.Window()
        self.window.set_border_width(5)
        self.window.set_title(_("Conversation log for %s") % email)
        self.window.set_default_size(650,350)
        self.window.set_position(gtk.WIN_POS_CENTER)

        textview = gtk.TextView()
        self.textBuffer = textview.get_buffer()
        self.textBuffer.create_tag('highlight', background = 'yellow')

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        self.textview = HtmlTextView(self.controller, self.textBuffer, scroll)
        self.textview.set_wrap_mode(gtk.WRAP_WORD_CHAR)
        self.textview.set_left_margin(6)
        self.textview.set_right_margin(6)
        self.textview.set_editable(False)
        self.textview.set_cursor_visible(False)

        scroll.add(self.textview)

        hbox = gtk.HBox(False, 5)
        saveButton = gtk.Button(stock=gtk.STOCK_SAVE)
        saveButton.connect("clicked", self.on_save_logs)

        refreshButton = gtk.Button(stock=gtk.STOCK_REFRESH)
        refreshButton.connect("clicked", self.on_refresh_log, email)

        closeButton = gtk.Button(stock=gtk.STOCK_CLOSE)
        closeButton.connect("clicked", lambda w: self.window.hide())
        
        ############ Search TreeView ###################
        self.search_active = False
        
        self.searchStore = gtk.ListStore(str, str, str, str)
        self.searchTree = gtk.TreeView(self.searchStore)
        self.searchTree.connect("row-activated", self.set_cursor)
        self.searchTree.set_rules_hint(True)
        cell = gtk.CellRendererText()
        
        nameCol = gtk.TreeViewColumn(_("Date"), cell, text=0)
        dateCol = gtk.TreeViewColumn(_("Time"), cell, text=1)
        timeCol = gtk.TreeViewColumn(_("Name"), cell, text=2)
        msgCol = gtk.TreeViewColumn(_("Message"), cell, text=3)
        
        nameCol.set_resizable(True)
        dateCol.set_resizable(True)
        timeCol.set_resizable(True)        
        msgCol.set_resizable(True)
        
        self.searchTree.append_column(nameCol)
        self.searchTree.append_column(dateCol)
        self.searchTree.append_column(timeCol)
        self.searchTree.append_column(msgCol)
        
        self.searchSw = gtk.ScrolledWindow()
        self.searchSw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.searchSw.add(self.searchTree)
        self.searchSw.set_size_request(100, 30)
        
        ##################################################
        
        #search box
        searchLabel = gtk.Label(_("Search:"))
        self.searchBox = gtk.Entry()
        self.searchBox.connect("key-press-event", self.enter_pressed)
        

        hbox.pack_end(saveButton, False, False)
        hbox.pack_end(refreshButton, False, False)
        hbox.pack_end(closeButton, False, False)
        hbox.pack_end(self.searchBox, False, False)
        hbox.pack_end(searchLabel, False, False)

        textRenderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_("Date"), textRenderer, markup=0)
        self.datesListstore = gtk.ListStore(str)

        self.datesTree = gtk.TreeView(self.datesListstore)
        self.datesTree.connect("cursor-changed", self.on_dates_cursor_change)
        self.datesTree.append_column(column)
        self.datesTree.set_headers_visible(False)

        datesScroll = gtk.ScrolledWindow()
        datesScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        datesScroll.add_with_viewport(self.datesTree)
        datesScroll.set_size_request(150, -1)


        hPaned = gtk.HPaned()
        hPaned.pack1(datesScroll)
        hPaned.pack2(scroll)

        vbox = gtk.VBox(spacing=5)
        vbox.pack_start(hPaned)
        vbox.pack_start(hbox, False, False)
        vbox.pack_start(self.searchSw)
        vbox.pack_start(gtk.Statusbar(), False, False)

        self.datesStamps = {}
        logsCant = len(self.fill_dates_tree(email))
        if not logsCant > 0:
            dialog.information(_("No logs were found for %s") % (email))
        else:
            self.window.add(vbox)
            self.window.show_all()
        
        self.searchSw.hide_all()   
示例#13
0
文件: dblogin.py 项目: xt0ph/tryton
    def __init__(self):
        # GTK Stuffs
        self.parent = common.get_toplevel_window()
        self.dialog = gtk.Dialog(title=_('Login'), parent=self.parent,
            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_icon(TRYTON_ICON)

        tooltips = common.Tooltips()
        button_cancel = gtk.Button(_('_Cancel'), use_underline=True)
        img_cancel = gtk.Image()
        img_cancel.set_from_stock('gtk-cancel', gtk.ICON_SIZE_BUTTON)
        button_cancel.set_image(img_cancel)
        button_cancel.set_always_show_image(True)
        tooltips.set_tip(button_cancel,
            _('Cancel connection to the Tryton server'))
        self.dialog.add_action_widget(button_cancel, gtk.RESPONSE_CANCEL)
        self.button_connect = gtk.Button(_('C_onnect'), use_underline=True)
        img_connect = gtk.Image()
        img_connect.set_from_stock('tryton-connect', gtk.ICON_SIZE_BUTTON)
        self.button_connect.set_image(img_connect)
        self.button_connect.set_always_show_image(True)
        self.button_connect.set_can_default(True)
        tooltips.set_tip(self.button_connect, _('Connect the Tryton server'))
        self.dialog.add_action_widget(self.button_connect, gtk.RESPONSE_OK)
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        alignment = gtk.Alignment(yalign=0, yscale=0, xscale=1)
        self.table_main = gtk.Table(3, 3, False)
        self.table_main.set_border_width(0)
        self.table_main.set_row_spacings(3)
        self.table_main.set_col_spacings(3)
        alignment.add(self.table_main)
        self.dialog.vbox.pack_start(alignment, True, True, 0)

        image = gtk.Image()
        image.set_from_file(os.path.join(PIXMAPS_DIR, 'tryton.png'))
        image.set_alignment(0.5, 1)
        ebox = gtk.EventBox()
        ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#1b2019"))
        ebox.add(image)
        self.table_main.attach(ebox, 0, 3, 0, 1, ypadding=2)

        self.profile_store = gtk.ListStore(gobject.TYPE_STRING,
            gobject.TYPE_BOOLEAN)
        self.combo_profile = gtk.ComboBox()
        cell = gtk.CellRendererText()
        self.combo_profile.pack_start(cell, True)
        self.combo_profile.add_attribute(cell, 'text', 0)
        self.combo_profile.add_attribute(cell, 'sensitive', 1)
        self.combo_profile.set_model(self.profile_store)
        self.combo_profile.connect('changed', self.profile_changed)
        self.profile_label = gtk.Label(set_underline(_(u'Profile:')))
        self.profile_label.set_use_underline(True)
        self.profile_label.set_justify(gtk.JUSTIFY_RIGHT)
        self.profile_label.set_alignment(1, 0.5)
        self.profile_label.set_padding(3, 3)
        self.profile_label.set_mnemonic_widget(self.combo_profile)
        self.profile_button = gtk.Button(set_underline(_('Manage profiles')),
            use_underline=True)
        self.profile_button.connect('clicked', self.profile_manage)
        self.table_main.attach(self.profile_label, 0, 1, 1, 2,
            xoptions=gtk.FILL)
        self.table_main.attach(self.combo_profile, 1, 2, 1, 2)
        self.table_main.attach(self.profile_button, 2, 3, 1, 2,
            xoptions=gtk.FILL)
        image = gtk.Image()
        image.set_from_stock('gtk-edit', gtk.ICON_SIZE_BUTTON)
        self.profile_button.set_image(image)
        self.profile_button.set_always_show_image(True)
        self.expander = gtk.Expander()
        self.expander.set_label(_('Host / Database information'))
        self.expander.connect('notify::expanded', self.expand_hostspec)
        self.table_main.attach(self.expander, 0, 3, 3, 4)
        self.label_host = gtk.Label(set_underline(_('Host:')))
        self.label_host.set_use_underline(True)
        self.label_host.set_justify(gtk.JUSTIFY_RIGHT)
        self.label_host.set_alignment(1, 0.5)
        self.label_host.set_padding(3, 3)
        self.entry_host = gtk.Entry()
        self.entry_host.connect_after('focus-out-event',
            self.clear_profile_combo)
        self.entry_host.set_activates_default(True)
        self.label_host.set_mnemonic_widget(self.entry_host)
        self.table_main.attach(self.label_host, 0, 1, 4, 5, xoptions=gtk.FILL)
        self.table_main.attach(self.entry_host, 1, 3, 4, 5)
        self.label_database = gtk.Label(set_underline(_('Database:')))
        self.label_database.set_use_underline(True)
        self.label_database.set_justify(gtk.JUSTIFY_RIGHT)
        self.label_database.set_alignment(1, 0.5)
        self.label_database.set_padding(3, 3)
        self.entry_database = gtk.Entry()
        self.entry_database.connect_after('focus-out-event',
            self.clear_profile_combo)
        self.entry_database.set_activates_default(True)
        self.label_database.set_mnemonic_widget(self.entry_database)
        self.table_main.attach(self.label_database, 0, 1, 5, 6,
            xoptions=gtk.FILL)
        self.table_main.attach(self.entry_database, 1, 3, 5, 6)
        self.entry_login = gtk.Entry()
        self.entry_login.set_activates_default(True)
        self.table_main.attach(self.entry_login, 1, 3, 6, 7)
        label_username = gtk.Label(set_underline(_("User name:")))
        label_username.set_use_underline(True)
        label_username.set_alignment(1, 0.5)
        label_username.set_padding(3, 3)
        label_username.set_mnemonic_widget(self.entry_login)
        self.table_main.attach(label_username, 0, 1, 6, 7, xoptions=gtk.FILL)

        # Profile informations
        self.profile_cfg = os.path.join(get_config_dir(), 'profiles.cfg')
        self.profiles = ConfigParser.SafeConfigParser()
        if not os.path.exists(self.profile_cfg):
            short_version = '.'.join(__version__.split('.', 2)[:2])
            name = 'demo%s.tryton.org' % short_version
            self.profiles.add_section(name)
            self.profiles.set(name, 'host', name)
            self.profiles.set(name, 'database', 'demo%s' % short_version)
            self.profiles.set(name, 'username', 'demo')
        else:
            self.profiles.read(self.profile_cfg)
        for section in self.profiles.sections():
            active = all(self.profiles.has_option(section, option)
                for option in ('host', 'database'))
            self.profile_store.append([section, active])
示例#14
0
文件: dblogin.py 项目: xt0ph/tryton
    def __init__(self, parent, profile_store, profiles, callback):
        self.profiles = profiles
        self.current_database = None
        self.old_profile, self.current_profile = None, None
        self.db_cache = None
        self.updating_db = False

        # GTK Stuffs
        self.parent = parent
        self.dialog = gtk.Dialog(title=_(u'Profile Editor'), parent=parent,
            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.ok_button = self.dialog.add_button(gtk.STOCK_OK,
            gtk.RESPONSE_ACCEPT)
        self.ok_button.set_always_show_image(True)
        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_icon(TRYTON_ICON)

        hpaned = gtk.HPaned()
        vbox_profiles = gtk.VBox(homogeneous=False, spacing=6)
        self.cell = gtk.CellRendererText()
        self.cell.set_property('editable', True)
        self.cell.connect('editing-started', self.edit_started)
        self.profile_tree = gtk.TreeView()
        self.profile_tree.set_model(profile_store)
        self.profile_tree.insert_column_with_attributes(-1, _(u'Profile'),
            self.cell, text=0)
        self.profile_tree.connect('cursor-changed', self.profile_selected)
        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.add(self.profile_tree)
        self.add_button = gtk.Button(_(u'_Add'), use_underline=True)
        self.add_button.connect('clicked', self.profile_create)
        add_image = gtk.Image()
        add_image.set_from_stock('gtk-add', gtk.ICON_SIZE_BUTTON)
        self.add_button.set_image(add_image)
        self.add_button.set_always_show_image(True)
        self.remove_button = gtk.Button(_(u'_Remove'), use_underline=True)
        self.remove_button.connect('clicked', self.profile_delete)
        remove_image = gtk.Image()
        remove_image.set_from_stock('gtk-remove', gtk.ICON_SIZE_BUTTON)
        self.remove_button.set_image(remove_image)
        self.remove_button.set_always_show_image(True)
        vbox_profiles.pack_start(scroll, expand=True, fill=True)
        vbox_profiles.pack_start(self.add_button, expand=False, fill=True)
        vbox_profiles.pack_start(self.remove_button, expand=False, fill=True)
        hpaned.add1(vbox_profiles)

        table = gtk.Table(4, 2, homogeneous=False)
        table.set_row_spacings(3)
        table.set_col_spacings(3)
        host = gtk.Label(set_underline(_(u'Host:')))
        host.set_use_underline(True)
        host.set_alignment(1, 0.5)
        host.set_padding(3, 3)
        self.host_entry = gtk.Entry()
        self.host_entry.connect('focus-out-event', self.display_dbwidget)
        self.host_entry.connect('changed', self.update_profiles, 'host')
        self.host_entry.set_activates_default(True)
        host.set_mnemonic_widget(self.host_entry)
        table.attach(host, 0, 1, 1, 2, yoptions=False, xoptions=gtk.FILL)
        table.attach(self.host_entry, 1, 2, 1, 2, yoptions=False)
        database = gtk.Label(set_underline(_(u'Database:')))
        database.set_use_underline(True)
        database.set_alignment(1, 0.5)
        database.set_padding(3, 3)
        self.database_entry = gtk.Entry()
        self.database_entry.connect('changed', self.dbentry_changed)
        self.database_entry.connect('changed', self.update_profiles,
            'database')
        self.database_entry.set_activates_default(True)
        self.database_label = gtk.Label()
        self.database_label.set_use_markup(True)
        self.database_label.set_alignment(0, 0.5)
        self.database_combo = gtk.ComboBox()
        dbstore = gtk.ListStore(gobject.TYPE_STRING)
        cell = gtk.CellRendererText()
        self.database_combo.pack_start(cell, True)
        self.database_combo.add_attribute(cell, 'text', 0)
        self.database_combo.set_model(dbstore)
        self.database_combo.connect('changed', self.dbcombo_changed)
        self.database_progressbar = gtk.ProgressBar()
        self.database_progressbar.set_text(_(u'Fetching databases list'))
        image = gtk.Image()
        image.set_from_stock('tryton-new', gtk.ICON_SIZE_BUTTON)
        db_box = gtk.VBox(homogeneous=True)
        db_box.pack_start(self.database_entry)
        db_box.pack_start(self.database_combo)
        db_box.pack_start(self.database_label)
        db_box.pack_start(self.database_progressbar)
        # Compute size_request of box in order to prevent "form jumping"
        width, height = 0, 0
        for child in db_box.get_children():
            cwidth, cheight = child.size_request()
            width, height = max(width, cwidth), max(height, cheight)
        db_box.set_size_request(width, height)
        table.attach(database, 0, 1, 2, 3, yoptions=False, xoptions=gtk.FILL)
        table.attach(db_box, 1, 2, 2, 3, yoptions=False)
        username = gtk.Label(set_underline(_(u'Username:'******'changed', self.update_profiles,
            'username')
        username.set_mnemonic_widget(self.username_entry)
        self.username_entry.set_activates_default(True)
        table.attach(username, 0, 1, 3, 4, yoptions=False, xoptions=gtk.FILL)
        table.attach(self.username_entry, 1, 2, 3, 4, yoptions=False)
        hpaned.add2(table)
        hpaned.set_position(250)

        self.dialog.vbox.pack_start(hpaned)
        self.dialog.set_default_size(640, 350)
        self.dialog.set_default_response(gtk.RESPONSE_ACCEPT)

        self.dialog.connect('close', lambda *a: False)
        self.dialog.connect('response', self.response)
        self.callback = callback
示例#15
0
    def __init__(self, *args, **kwargs):
        super(WinCSV, self).__init__(*args, **kwargs)

        self.dialog = gtk.Dialog(parent=self.parent,
                                 flags=gtk.DIALOG_DESTROY_WITH_PARENT)
        Main().add_window(self.dialog)
        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_icon(TRYTON_ICON)
        self.dialog.connect('response', self.response)

        dialog_vbox = gtk.VBox()

        hbox_mapping = gtk.HBox(True)
        dialog_vbox.pack_start(hbox_mapping, True, True, 0)

        frame_fields = gtk.Frame()
        frame_fields.set_shadow_type(gtk.SHADOW_NONE)
        viewport_fields = gtk.Viewport()
        scrolledwindow_fields = gtk.ScrolledWindow()
        scrolledwindow_fields.set_policy(gtk.POLICY_AUTOMATIC,
                                         gtk.POLICY_AUTOMATIC)
        viewport_fields.add(scrolledwindow_fields)
        frame_fields.add(viewport_fields)
        label_all_fields = gtk.Label(_('<b>All fields</b>'))
        label_all_fields.set_use_markup(True)
        frame_fields.set_label_widget(label_all_fields)
        hbox_mapping.pack_start(frame_fields, True, True, 0)

        vbox_buttons = gtk.VBox(False, 10)
        vbox_buttons.set_border_width(5)
        hbox_mapping.pack_start(vbox_buttons, False, True, 0)

        button_add = gtk.Button(_('_Add'), stock=None, use_underline=True)
        button_add.set_image(
            IconFactory.get_image('tryton-add', gtk.ICON_SIZE_BUTTON))
        button_add.set_always_show_image(True)
        button_add.connect_after('clicked', self.sig_sel)
        vbox_buttons.pack_start(button_add, False, False, 0)

        button_remove = gtk.Button(_('_Remove'),
                                   stock=None,
                                   use_underline=True)
        button_remove.set_image(
            IconFactory.get_image('tryton-remove', gtk.ICON_SIZE_BUTTON))
        button_remove.set_always_show_image(True)
        button_remove.connect_after('clicked', self.sig_unsel)
        vbox_buttons.pack_start(button_remove, False, False, 0)

        button_remove_all = gtk.Button(_('_Clear'),
                                       stock=None,
                                       use_underline=True)
        button_remove_all.set_image(
            IconFactory.get_image('tryton-clear', gtk.ICON_SIZE_BUTTON))
        button_remove_all.set_always_show_image(True)
        button_remove_all.connect_after('clicked', self.sig_unsel_all)
        vbox_buttons.pack_start(button_remove_all, False, False, 0)

        hseparator_buttons = gtk.HSeparator()
        vbox_buttons.pack_start(hseparator_buttons, False, False, 3)

        self.add_buttons(vbox_buttons)

        frame_fields_selected = gtk.Frame()
        frame_fields_selected.set_shadow_type(gtk.SHADOW_NONE)
        viewport_fields_selected = gtk.Viewport()
        scrolledwindow_fields_selected = gtk.ScrolledWindow()
        scrolledwindow_fields_selected.set_policy(gtk.POLICY_AUTOMATIC,
                                                  gtk.POLICY_AUTOMATIC)
        viewport_fields_selected.add(scrolledwindow_fields_selected)
        frame_fields_selected.add(viewport_fields_selected)
        label_fields_selected = gtk.Label(_('<b>Fields selected</b>'))
        label_fields_selected.set_use_markup(True)
        frame_fields_selected.set_label_widget(label_fields_selected)
        hbox_mapping.pack_start(frame_fields_selected, True, True, 0)

        frame_csv_param = gtk.Frame()
        frame_csv_param.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        dialog_vbox.pack_start(frame_csv_param, False, True, 0)
        alignment_csv_param = gtk.Alignment(0.5, 0.5, 1, 1)
        alignment_csv_param.set_padding(7, 7, 7, 7)
        frame_csv_param.add(alignment_csv_param)

        vbox_csv_param = gtk.VBox()
        alignment_csv_param.add(vbox_csv_param)

        self.add_chooser(vbox_csv_param)

        expander_csv = gtk.Expander()
        vbox_csv_param.pack_start(expander_csv, False, True, 0)
        label_csv_param = gtk.Label(_('CSV Parameters'))
        expander_csv.set_label_widget(label_csv_param)
        table = gtk.Table(2, 4, False)
        table.set_border_width(8)
        table.set_row_spacings(9)
        table.set_col_spacings(8)
        expander_csv.add(table)

        label_csv_delimiter = gtk.Label(_('Delimiter:'))
        label_csv_delimiter.set_alignment(1, 0.5)
        table.attach(label_csv_delimiter, 0, 1, 0, 1)
        self.csv_delimiter = gtk.Entry()
        self.csv_delimiter.set_max_length(1)
        if os.name == 'nt' and ',' == locale.localeconv()['decimal_point']:
            delimiter = ';'
        else:
            delimiter = ','
        self.csv_delimiter.set_text(delimiter)
        self.csv_delimiter.set_width_chars(1)
        label_csv_delimiter.set_mnemonic_widget(self.csv_delimiter)
        table.attach(self.csv_delimiter, 1, 2, 0, 1)

        label_csv_quotechar = gtk.Label(_("Quote char:"))
        label_csv_quotechar.set_alignment(1, 0.5)
        table.attach(label_csv_quotechar, 2, 3, 0, 1)
        self.csv_quotechar = gtk.Entry()
        self.csv_quotechar.set_text("\"")
        self.csv_quotechar.set_width_chars(1)
        label_csv_quotechar.set_mnemonic_widget(self.csv_quotechar)
        table.attach(self.csv_quotechar, 3, 4, 0, 1)

        label_csv_enc = gtk.Label(_("Encoding:"))
        label_csv_enc.set_alignment(1, 0.5)
        table.attach(label_csv_enc, 0, 1, 1, 2)
        if hasattr(gtk, 'ComboBoxText'):
            self.csv_enc = gtk.ComboBoxText()
        else:
            self.csv_enc = gtk.combo_box_new_text()
        for i, encoding in enumerate(encodings):
            self.csv_enc.append_text(encoding)
            if ((os.name == 'nt' and encoding == 'cp1252')
                    or (os.name != 'nt' and encoding == 'utf_8')):
                self.csv_enc.set_active(i)
        label_csv_enc.set_mnemonic_widget(self.csv_enc)
        table.attach(self.csv_enc, 1, 2, 1, 2)

        self.add_csv_header_param(table)

        button_cancel = self.dialog.add_button(set_underline(_("Cancel")),
                                               gtk.RESPONSE_CANCEL)
        button_cancel.set_image(
            IconFactory.get_image('tryton-cancel', gtk.ICON_SIZE_BUTTON))

        button_ok = self.dialog.add_button(set_underline(_("OK")),
                                           gtk.RESPONSE_OK)
        button_ok.set_image(
            IconFactory.get_image('tryton-ok', gtk.ICON_SIZE_BUTTON))

        self.dialog.vbox.pack_start(dialog_vbox)

        self.view1 = gtk.TreeView()
        self.view1.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        self.view1.connect('row-expanded', self.on_row_expanded)
        scrolledwindow_fields.add(self.view1)
        self.view2 = gtk.TreeView()
        self.view2.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        scrolledwindow_fields_selected.add(self.view2)
        self.view1.set_headers_visible(False)
        self.view2.set_headers_visible(False)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_('Field name'), cell, text=0)
        self.view1.append_column(column)

        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_('Field name'), cell, text=0)
        self.view2.append_column(column)

        self.model1 = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        self.model2 = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)

        self.model_populate(self._get_fields(self.model))

        self.view1.set_model(self.model1)
        self.view1.connect('row-activated', self.sig_sel)
        self.view2.set_model(self.model2)
        self.view2.connect('row-activated', self.sig_unsel)

        self.dialog.show_all()
        self.show()

        self.register()

        if sys.platform != 'darwin':
            self.view2.drag_source_set(
                gtk.gdk.BUTTON1_MASK | gtk.gdk.BUTTON3_MASK, [
                    gtk.TargetEntry.new('EXPORT_TREE', gtk.TARGET_SAME_WIDGET,
                                        0)
                ], gtk.gdk.ACTION_MOVE)
            self.view2.drag_dest_set(gtk.DEST_DEFAULT_ALL, [
                gtk.TargetEntry.new('EXPORT_TREE', gtk.TARGET_SAME_WIDGET, 0)
            ], gtk.gdk.ACTION_MOVE)
            self.view2.connect('drag-begin', self.drag_begin)
            self.view2.connect('drag-motion', self.drag_motion)
            self.view2.connect('drag-drop', self.drag_drop)
            self.view2.connect("drag-data-get", self.drag_data_get)
            self.view2.connect('drag-data-received', self.drag_data_received)
            self.view2.connect('drag-data-delete', self.drag_data_delete)
示例#16
0
        widget.set_size_request(150, -1)
        widget.show()

        box.pack_start(lab, 0, 0, 0)
        if full:
            box.pack_start(widget, 1, 1, 1)
        else:
            box.pack_start(widget, 0, 0, 0)
        box.show()

        # pylint: disable-msg=E1101
        if full:
            self.vbox.pack_start(box, 1, 1, 1)
        else:
            self.vbox.pack_start(box, 0, 0, 0)

        self.__fields[label] = widget

    def get_field(self, label):
        return self.__fields.get(label, None)


if __name__ == "__main__":
    # pylint: disable-msg=C0103
    d = FieldDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK))
    d.add_field("Foo", gtk.Entry())
    d.add_field("Bar", make_choice(["A", "B"]))
    d.run()
    gtk.main()
    d.destroy()
示例#17
0
    def __init__(self, image):
        self.image = image

        self.dialog = gimpui.Dialog(PLUGIN_TITLE, None, None, 0, None, None)
        self.dialog.set_transient()
        self.dialog.set_default_size(850, 660)
        #    self.dialog.set_size_request(850,660)
        self.dialog.set_border_width(8)
        dialog_position = retrieve_setting('dialog_position')
        if dialog_position is not None:
            self.dialog.move(*dialog_position)

        self.directory_chooser_label = gtk.Label()
        self.directory_chooser_label.set_markup(
            "<b>Choose output directory</b>")
        self.directory_chooser_label.set_alignment(0.0, 0.5)

        self.directory_chooser = gtk.FileChooserWidget(
            action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)

        self.hbox_file_format = gtk.HBox(homogeneous=False)
        self.hbox_file_format.set_spacing(5)
        self.file_format_label = gtk.Label()
        self.file_format_label.set_markup("<b>File format:</b>")
        self.file_format_label.set_alignment(0.0, 0.5)
        self.file_format_label.set_size_request(100, -1)
        self.file_format_entry = gtk.Entry()
        self.file_format_entry.set_size_request(100, -1)
        self.file_format_error_icon = gtk.Image()
        self.file_format_error_icon.set_from_stock(gtk.STOCK_STOP,
                                                   gtk.ICON_SIZE_BUTTON)
        self.file_format_error_message = gtk.Label()
        self.file_format_error_message.set_alignment(0.0, 0.5)
        self.hbox_file_format.pack_start(self.file_format_label, expand=False)
        self.hbox_file_format.pack_start(self.file_format_entry, expand=False)
        self.hbox_file_format.pack_start(self.file_format_error_icon,
                                         expand=False)
        self.hbox_file_format.pack_start(self.file_format_error_message,
                                         expand=False)

        self.hbox_export_options = gtk.HBox(homogeneous=False)
        self.export_options_layer_groups = gtk.CheckButton(
            "Treat layer groups as directories")
        self.export_options_ignore_invisible = gtk.CheckButton(
            "Ignore invisible layers")
        self.export_options_is_autocrop = gtk.CheckButton("Autocrop layers")
        self.export_options_use_image_size = gtk.CheckButton(
            "Use image size instead of layer size")
        self.hbox_export_options.pack_start(self.export_options_layer_groups)
        self.hbox_export_options.pack_start(
            self.export_options_ignore_invisible)
        self.hbox_export_options.pack_start(self.export_options_is_autocrop)
        self.hbox_export_options.pack_start(self.export_options_use_image_size)

        self.hbox_action_area = gtk.HBox(homogeneous=False)
        self.export_layers_button = gtk.Button(label="Export Layers")
        self.export_layers_button.set_size_request(110, -1)
        self.cancel_button = gtk.Button(label="Cancel")
        self.cancel_button.set_size_request(110, -1)
        self.progress_bar = gimpui.ProgressBar()
        #     self.progress_bar = gtk.ProgressBar()

        self.hbox_action_area.set_spacing(8)
        self.hbox_action_area.set_border_width(8)
        self.hbox_action_area.pack_start(self.progress_bar,
                                         expand=True,
                                         fill=True)
        self.hbox_action_area.pack_end(self.export_layers_button,
                                       expand=False,
                                       fill=True)
        self.hbox_action_area.pack_end(self.cancel_button,
                                       expand=False,
                                       fill=True)

        self.dialog.vbox.set_spacing(3)
        self.dialog.vbox.pack_start(self.directory_chooser_label,
                                    expand=False,
                                    fill=False)
        self.dialog.vbox.pack_start(self.directory_chooser, padding=5)
        self.dialog.vbox.pack_start(self.hbox_file_format,
                                    expand=False,
                                    fill=False)
        self.dialog.vbox.pack_start(self.hbox_export_options,
                                    expand=False,
                                    fill=False)
        self.dialog.vbox.pack_start(self.hbox_action_area,
                                    expand=False,
                                    fill=False)

        self.dialog.connect("response", self.response)
        self.cancel_button.connect("clicked", self.cancel)
        self.export_layers_button.connect("clicked", self.export)

        # Assign last used values if last export was successful and
        # if there are any, otherwise use default values.
        selected_directory = retrieve_setting('output_directory')
        if selected_directory is not None:
            self.directory_chooser.set_current_folder(selected_directory)
        else:
            if self.image.uri is not None:
                self.directory_chooser.set_uri(self.image.uri)
            else:
                self.directory_chooser.set_current_folder(
                    ExportLayersPlugin.
                    PARAMS_DEFAULT_VALUES['output_directory'])
        self.file_format_entry.set_text(
            retrieve_setting(
                'file_format',
                ExportLayersPlugin.PARAMS_DEFAULT_VALUES['file_format']))
        self.export_options_layer_groups.set_active(
            retrieve_setting(
                'layer_groups_as_directories', ExportLayersPlugin.
                PARAMS_DEFAULT_VALUES['layer_groups_as_directories']))
        self.export_options_ignore_invisible.set_active(
            retrieve_setting(
                'ignore_invisible',
                ExportLayersPlugin.PARAMS_DEFAULT_VALUES['ignore_invisible']))
        self.export_options_is_autocrop.set_active(
            retrieve_setting(
                'is_autocrop',
                ExportLayersPlugin.PARAMS_DEFAULT_VALUES['is_autocrop']))
        self.export_options_use_image_size.set_active(
            retrieve_setting(
                'use_image_size',
                ExportLayersPlugin.PARAMS_DEFAULT_VALUES['use_image_size']))

        self.dialog.show_all()
        # Action area is unused, the dialog bottom would otherwise be filled with empty space.
        self.dialog.action_area.hide()

        self.display_label_error_message()
        self.progress_bar.set_visible(False)
示例#18
0
    def initialize_detail(self):
        self.detail_container = self.get_widget("detail_container")

        vbox = gtk.VBox(False, 6)

        # Set up the Tag line
        label = gtk.Label(_("Name:"))
        label.set_size_request(90, -1)
        label.set_properties(xalign=0, yalign=.5)
        self.tag_entry = gtk.Entry()
        self.tag_name_container = gtk.HBox(False, 0)
        self.tag_name_container.pack_start(label, False, False, 0)
        self.tag_name_container.pack_start(self.tag_entry, False, False, 0)
        vbox.pack_start(self.tag_name_container, False, False, 0)

        # Set up the Commit-sha line
        label = gtk.Label(_("Revision:"))
        label.set_size_request(90, -1)
        label.set_properties(xalign=0, yalign=.5)
        self.start_point_entry = gtk.Entry()
        self.start_point_entry.set_size_request(300, -1)
        self.start_point_container = gtk.HBox(False, 0)
        if self.revision_obj.value:
            self.start_point_entry.set_text(six.text_type(self.revision_obj))
        self.log_dialog_button = gtk.Button()
        self.log_dialog_button.connect("clicked",
                                       self.on_log_dialog_button_clicked)
        image = gtk.Image()
        image.set_from_icon_name("rabbitvcs-show_log", 2)
        self.log_dialog_button.set_image(image)
        self.start_point_container.pack_start(label, False, False, 0)
        self.start_point_container.pack_start(self.start_point_entry, False,
                                              False, 0)
        self.start_point_container.pack_start(self.log_dialog_button, False,
                                              False, 0)
        vbox.pack_start(self.start_point_container, False, False, 0)

        # Set up the Log Message Entry line
        label = gtk.Label(_("Message:"))
        label.set_size_request(90, -1)
        label.set_properties(xalign=0, yalign=0)
        self.message_entry = rabbitvcs.ui.widget.TextView()
        self.message_entry.view.set_size_request(300, 75)
        swin = gtk.ScrolledWindow()
        swin.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        swin.add(self.message_entry.view)
        self.message_entry_container = gtk.HBox(False, 0)
        self.message_entry_container.pack_start(label, False, False, 0)
        self.message_entry_container.pack_start(swin, False, False, 0)
        vbox.pack_start(self.message_entry_container, False, False, 0)

        # Set up Save button
        label = gtk.Label("")
        label.set_size_request(90, -1)
        self.save_button = gtk.Button(label=_("Save"))
        self.save_button.connect("clicked", self.on_save_clicked)
        self.save_container = gtk.HBox(False, 0)
        self.save_container.pack_start(label, False, False, 0)
        self.save_container.pack_start(self.save_button, False, False, 0)
        vbox.pack_start(self.save_container, False, False, 0)

        # Set up the tagger line
        label = gtk.Label(_("Tagger:"))
        label.set_size_request(90, -1)
        label.set_properties(xalign=0, yalign=0)
        self.tagger_label = gtk.Label("")
        self.tagger_label.set_properties(xalign=0, yalign=0, selectable=True)
        self.tagger_label.set_line_wrap(True)
        self.tagger_container = gtk.HBox(False, 0)
        self.tagger_container.pack_start(label, False, False, 0)
        self.tagger_container.pack_start(self.tagger_label, False, False, 0)
        vbox.pack_start(self.tagger_container, False, False, 0)

        # Set up the Date line
        label = gtk.Label(_("Date:"))
        label.set_size_request(90, -1)
        label.set_properties(xalign=0, yalign=0)
        self.date_label = gtk.Label("")
        self.date_label.set_properties(xalign=0, yalign=0, selectable=True)
        self.date_container = gtk.HBox(False, 0)
        self.date_container.pack_start(label, False, False, 0)
        self.date_container.pack_start(self.date_label, False, False, 0)
        vbox.pack_start(self.date_container, False, False, 0)

        # Set up the Revision line
        label = gtk.Label(_("Revision:"))
        label.set_size_request(90, -1)
        label.set_properties(xalign=0, yalign=0)
        self.revision_label = gtk.Label("")
        self.revision_label.set_properties(xalign=0, selectable=True)
        self.revision_label.set_line_wrap(True)
        self.revision_container = gtk.HBox(False, 0)
        self.revision_container.pack_start(label, False, False, 0)
        self.revision_container.pack_start(self.revision_label, False, False,
                                           0)
        vbox.pack_start(self.revision_container, False, False, 0)

        # Set up the Log Message line
        label = gtk.Label(_("Message:"))
        label.set_size_request(90, -1)
        label.set_properties(xalign=0, yalign=0)
        self.message_label = gtk.Label("")
        self.message_label.set_properties(xalign=0, yalign=0, selectable=True)
        self.message_label.set_line_wrap(True)
        self.message_label.set_size_request(250, -1)
        self.message_container = gtk.HBox(False, 0)
        self.message_container.pack_start(label, False, False, 0)
        self.message_container.pack_start(self.message_label, False, False, 0)
        vbox.pack_start(self.message_container, False, False, 0)

        self.add_containers = [
            self.tag_name_container, self.message_entry_container,
            self.start_point_container, self.save_container
        ]

        self.view_containers = [
            self.tag_name_container, self.tagger_container,
            self.date_container, self.revision_container,
            self.message_container
        ]

        self.all_containers = [
            self.tag_name_container, self.tagger_container,
            self.date_container, self.revision_container,
            self.message_container, self.message_entry_container,
            self.save_container, self.start_point_container
        ]

        vbox.show()
        self.detail_container.add(vbox)
示例#19
0
 def fusion_dialog(self):
     dialog = gtk.Dialog('CUT PARAMETERS', self.W,
                         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                         (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT,
                          gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
     topL = gtk.Label('Items with a *** are mandatory')
     infL = gtk.Label('For Material # {}\n{}'.format(self.fNUM, self.fNAM))
     dNUl = gtk.Label('Material Number ***')
     dNUl.set_alignment(0, 1)
     dNU = gtk.Entry()
     dNU.set_text(self.fNUM)
     dNU.set_alignment(0.95)
     dNAl = gtk.Label('Material Name')
     dNAl.set_alignment(0, 1)
     dNA = gtk.Entry()
     dNA.set_text(self.fNAM)
     dNA.set_alignment(0.95)
     dKWl = gtk.Label('Kerf Width')
     dKWl.set_alignment(0, 1)
     dKW = gtk.Entry()
     dKW.set_text(self.fKW)
     dKW.set_alignment(0.95)
     dTHC = gtk.CheckButton('THC Enabled')
     dTHC.set_active(self.fTHC)
     dPHl = gtk.Label('Pierce Height ***')
     dPHl.set_alignment(0, 1)
     dPH = gtk.Entry()
     dPH.set_text(self.fPH)
     dPH.set_alignment(0.95)
     dPDl = gtk.Label('Pierce Delay ***')
     dPDl.set_alignment(0, 1)
     dPD = gtk.Entry()
     dPD.set_text(self.fPD)
     dPD.set_alignment(0.95)
     dPJHl = gtk.Label('Puddle Jump Height')
     dPJHl.set_alignment(0, 1)
     dPJH = gtk.Entry()
     dPJH.set_text(self.fPJH)
     dPJH.set_alignment(0.95)
     dPJDl = gtk.Label('Puddle Jump Delay')
     dPJDl.set_alignment(0, 1)
     dPJD = gtk.Entry()
     dPJD.set_text(self.fPJD)
     dPJD.set_alignment(0.95)
     dCHl = gtk.Label('Cut Height ***')
     dCHl.set_alignment(0, 1)
     dCH = gtk.Entry()
     dCH.set_text(self.fCH)
     dCH.set_alignment(0.95)
     dCSl = gtk.Label('Cut Speed ***')
     dCSl.set_alignment(0, 1)
     dCS = gtk.Entry()
     dCS.set_text(self.fCS)
     dCS.set_alignment(0.95)
     dCAl = gtk.Label('Cut Amps')
     dCAl.set_alignment(0, 1)
     dCA = gtk.Entry()
     dCA.set_text(self.fCA)
     dCA.set_alignment(0.95)
     dCVl = gtk.Label('Cut Volts')
     dCVl.set_alignment(0, 1)
     dCV = gtk.Entry()
     dCV.set_text(self.fCV)
     dCV.set_alignment(0.95)
     dPEl = gtk.Label('Pause At End Of Cut')
     dPEl.set_alignment(0, 1)
     dPE = gtk.Entry()
     dPE.set_text(self.fPE)
     dPE.set_alignment(0.95)
     dGPl = gtk.Label('Gas Pressure')
     dGPl.set_alignment(0, 1)
     dGP = gtk.Entry()
     dGP.set_text(self.fGP)
     dGP.set_alignment(0.95)
     dCMl = gtk.Label('Cut Mode')
     dCMl.set_alignment(0, 1)
     dCM = gtk.Entry()
     dCM.set_text(self.fCM)
     dCM.set_alignment(0.95)
     dialog.vbox.add(topL)
     if self.inManual.get_active():
         dialog.vbox.add(dNUl)
         dialog.vbox.add(dNU)
         dialog.vbox.add(dNAl)
         dialog.vbox.add(dNA)
         dialog.vbox.add(dKWl)
         dialog.vbox.add(dKW)
     else:
         dialog.vbox.add(infL)
     dialog.vbox.add(dTHC)
     dialog.vbox.add(dPHl)
     dialog.vbox.add(dPH)
     dialog.vbox.add(dPDl)
     dialog.vbox.add(dPD)
     dialog.vbox.add(dPJHl)
     dialog.vbox.add(dPJH)
     dialog.vbox.add(dPJDl)
     dialog.vbox.add(dPJD)
     dialog.vbox.add(dCHl)
     dialog.vbox.add(dCH)
     if self.inManual.get_active():
         dialog.vbox.add(dCSl)
         dialog.vbox.add(dCS)
     dialog.vbox.add(dCAl)
     dialog.vbox.add(dCA)
     dialog.vbox.add(dCVl)
     dialog.vbox.add(dCV)
     dialog.vbox.add(dPEl)
     dialog.vbox.add(dPE)
     dialog.vbox.add(dGPl)
     dialog.vbox.add(dGP)
     dialog.vbox.add(dCMl)
     dialog.vbox.add(dCM)
     dialog.show_all()
     response = dialog.run()
     if self.inManual.get_active():
         self.fNUM = dNU.get_text()
         self.fNAM = dNA.get_text()
         self.fKW = dKW.get_text()
     if dTHC.get_active():
         self.fTHC = 1
     else:
         self.fTHC = 0
     self.fPH = dPH.get_text()
     self.fPD = dPD.get_text()
     self.fPJH = dPJH.get_text()
     self.fPJD = dPJD.get_text()
     self.fCH = dCH.get_text()
     if self.inManual.get_active():
         self.fCS = dCS.get_text()
     self.fCA = dCA.get_text()
     self.fCV = dCV.get_text()
     self.fPE = dPE.get_text()
     self.fGP = dGP.get_text()
     self.fCM = dCM.get_text()
     dialog.destroy()
     return response
示例#20
0
    def build_handset(self):
        self.arrow_stepval = 1.0

        widgets = {}

        # Place arrow buttons
        off_xv = 220
        off_yh = 150

        btns = widgets.setdefault('buttons', {})
        for x, y, name, axis, mult in (
            (off_xv, off_yh - 140, 'up3', 0, 10),
            (off_xv, off_yh - 100, 'up2', 0, 3),
            (off_xv, off_yh - 60, 'up1', 0, 1),
            (off_xv - 170, off_yh, 'left3', 1, 10),
            (off_xv - 130, off_yh, 'left2', 1, 3),
            (off_xv - 90, off_yh, 'left1', 1, 1),
            (off_xv + 80, off_yh, 'right1', 1, -1),
            (off_xv + 120, off_yh, 'right2', 1, -3),
            (off_xv + 160, off_yh, 'right3', 1, -10),
            (off_xv, off_yh + 60, 'down1', 0, -1),
            (off_xv, off_yh + 100, 'down2', 0, -3),
            (off_xv, off_yh + 140, 'down3', 0, -10),
        ):
            btn = self._make_button(name)
            btn.connect("clicked", self.arrowMove, axis, mult)
            btns[name] = btn
            self.lw.put(btn, x, y)

        # Place entries
        ents = widgets.setdefault('entries', {})
        for x, y, width, name in ((off_xv - 35, off_yh + 5, 10, 'mainstep'), ):
            ent = gtk.Entry()
            ent.set_alignment(1.0)
            ent.set_text("0")
            ent.set_width_chars(width)
            ent.show()
            ents[name] = ent
            self.lw.put(ent, x, y)

        # Place spin buttons
        for x, y, name in ((20, 250, 'lspin'), (120, 250, 'rspin')):
            ent = gtk.SpinButton()
            ent.show()
            ent.set_alignment(1.0)
            ent.set_update_policy(gtk.UPDATE_ALWAYS)
            # this seems to force size
            ent.set_range(-1000, 1000)
            ents[name] = ent
            self.lw.put(ent, x, y)

        # Place labels
        lbls = widgets.setdefault('labels', {})
        for x, y, txt, name in ((off_xv + 45, 210 + 5, 'x1',
                                 'x1'), (off_xv + 45, 250 + 5, 'x3',
                                         'x3'), (off_xv + 45, 290 + 5, 'x10',
                                                 'x10'), (off_xv, off_yh - 18,
                                                          'Step', 'mainstep'),
                                (off_xv - 5, off_yh + 35, 'arcsec',
                                 'mainunit'), (20, 30, 'Mode', 'mode'),
                                (20, 232, '+N/-S',
                                 'lstep'), (120, 232, '+E/-W', 'rstep'),
                                (20, 275, 'arcsec', 'lstepunit'),
                                (120, 275, 'arcsec', 'rstepunit')):
            lbl = gtk.Label(txt)
            lbl.show()
            lbls[name] = lbl
            self.lw.put(lbl, x, y)

        # Compass
        lbl = self._make_compass('N', 'S', 'E', 'W')
        lbls['compass'] = lbl
        self.lw.put(lbl, off_xv + 80, off_yh - 120)

        # Place buttons
        btns = widgets['buttons']
        btn = gtk.Button('Move')
        #btn.set_size(10, -1)
        btn.connect("clicked", self.execute)
        btn.show()
        btns['move'] = btn
        self.lw.put(btn, 20, 300)

        # Mode drop-down
        cbox = gtk.combo_box_new_text()
        cbox.show()
        cbox.connect("changed", self.changeMode)
        btns['mode'] = cbox
        self.lw.put(cbox, 20, 50)

        self.widgets = widgets
示例#21
0
    def caja3(self, homogeneous, spacing, expand, fill, padding):

        caja = gtk.HBox(homogeneous, spacing)
        caja.set_border_width(7)

        rama = gtk.Label("Rama:")
        caja.pack_start(rama, False, False, 5)
        rama.show()

        global texto2
        texto2 = gtk.Entry()
        texto2.set_text("pruebas")
        texto2.set_sensitive(True)
        caja.pack_start(texto2, True, True, 5)
        texto2.show()

        seccion = gtk.Label("Sección:")
        caja.pack_start(seccion, False, False, 5)
        seccion.show()

        global texto3
        texto3 = gtk.Entry()
        texto3.set_text("usuarios")
        texto3.set_sensitive(True)
        caja.pack_start(texto3, True, True, 5)
        texto3.show()

        boton = gtk.Button("   Validar   ")

        #-------------Método para crear el hilo del método validar los repositorios-------------#
        def hilo_validar_remotos(self):
            hilo = threading.Thread(target=validar_remotos, args=self)
            hilo.start()

        #~~~~~~~~ Método para validar los repositorios remotos ~~~~~~~~~#
        def validar_remotos(self):

            if texto5.get_text() == "" or texto2.get_text(
            ) == "" or texto3.get_text() == "":
                gtk.gdk.threads_enter()
                error = gtk.MessageDialog(
                    parent=None,
                    flags=0,
                    type=gtk.MESSAGE_ERROR,
                    buttons=gtk.BUTTONS_CLOSE,
                    message_format=
                    "Debe tener todos los campos llenos para validar")
                error.run()
                error.destroy()
                gtk.gdk.threads_leave()
            else:
                try:
                    urllib.urlopen(texto5.get_text())

                    if textbuffer.get_text(*textbuffer.get_bounds()).find(
                            texto5.get_text()) >= 0:
                        gtk.gdk.threads_enter()
                        message = gtk.MessageDialog(
                            parent=None,
                            flags=0,
                            type=gtk.MESSAGE_WARNING,
                            buttons=gtk.BUTTONS_CLOSE,
                            message_format="La dirección ya ha sido agregada")
                        message.run()
                        message.hide()
                        gtk.gdk.threads_leave()

                    else:
                        gtk.gdk.threads_enter()
                        textbuffer.set_text(
                            textbuffer.get_text(*textbuffer.get_bounds()) +
                            "deb " + texto5.get_text() + ' ' +
                            texto2.get_text() + ' ' + texto3.get_text() + "\n")
                        gtk.gdk.threads_leave()

                except IOError:
                    gtk.gdk.threads_enter()
                    errorURL = gtk.MessageDialog(
                        parent=None,
                        flags=0,
                        type=gtk.MESSAGE_ERROR,
                        buttons=gtk.BUTTONS_CLOSE,
                        message_format=
                        "Debe introducir URL validas para el repositorio")
                    errorURL.run()
                    errorURL.destroy()
                    gtk.gdk.threads_leave()

        boton.connect("clicked", hilo_validar_remotos)
        caja.pack_start(boton, False, False, 5)
        boton.show()

        return caja
示例#22
0
    def __init__(self, name, toolbox, method):
        debug.mainthreadTest()
        toolboxGUI.GfxToolbox.__init__(self, name, toolbox)
        self.method = method  # RegisteredClass of selection methods
        self.points = []  # locations of mouse events
        # Was a modifier key pressed during the last button event?
        self.shift = 0
        self.ctrl = 0

        outerbox = gtk.VBox(spacing=2)
        self.gtk.add(outerbox)

        ##        scroll = gtk.ScrolledWindow()
        ##        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        ##        outerbox.pack_start(scroll, expand=1, fill=1)

        # Retrieve the registered class factory from the subclass.
        self.selectionMethodFactory = self.methodFactory()
        # self.selectionMethodFactory = regclassfactory.RegisteredClassFactory(
        #     method.registry, title="Method:", name="Method")
        ##        scroll.add_with_viewport(self.selectionMethodFactory.gtk)
        outerbox.pack_start(self.selectionMethodFactory.gtk, expand=1, fill=1)
        self.historian = historian.Historian(self.setHistory,
                                             self.sensitizeHistory)
        self.selectionMethodFactory.set_callback(self.historian.stateChangeCB)

        # Undo, Redo, Clear, and Invert buttons.  The callbacks for
        # these have to be defined in the derived classes.
        hbox = gtk.HBox(homogeneous=True, spacing=2)
        outerbox.pack_start(hbox, expand=0, fill=0)
        self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO)
        self.redobutton = gtk.Button(stock=gtk.STOCK_REDO)
        hbox.pack_start(self.undobutton, expand=1, fill=1)
        hbox.pack_start(self.redobutton, expand=1, fill=1)
        gtklogger.setWidgetName(self.undobutton, "Undo")
        gtklogger.setWidgetName(self.redobutton, "Redo")
        gtklogger.connect(self.undobutton, 'clicked', self.undoCB)
        gtklogger.connect(self.redobutton, 'clicked', self.redoCB)
        tooltips.set_tooltip_text(self.undobutton,
                                  "Undo the previous selection operation.")
        tooltips.set_tooltip_text(self.redobutton,
                                  "Redo an undone selection operation.")

        self.clearbutton = gtk.Button(stock=gtk.STOCK_CLEAR)
        gtklogger.setWidgetName(self.clearbutton, "Clear")
        hbox.pack_start(self.clearbutton, expand=1, fill=1)
        gtklogger.connect(self.clearbutton, 'clicked', self.clearCB)
        tooltips.set_tooltip_text(self.clearbutton, "Unselect all objects.")

        self.invertbutton = gtk.Button('Invert')
        gtklogger.setWidgetName(self.invertbutton, "Invert")
        hbox.pack_start(self.invertbutton, expand=1, fill=1)
        gtklogger.connect(self.invertbutton, 'clicked', self.invertCB)
        tooltips.set_tooltip_text(
            self.invertbutton,
            "Select all unselected objects, and deselect all selected objects."
        )

        # Selection history
        frame = gtk.Frame('History')
        frame.set_shadow_type(gtk.SHADOW_IN)
        outerbox.pack_start(frame, expand=0, fill=0)
        vbox = gtk.VBox()

        frame.add(vbox)

        table = gtk.Table(rows=2, columns=3)
        vbox.pack_start(table, expand=0, fill=0)
        table.attach(gtk.Label('down'), 0, 1, 0, 1, xoptions=0, yoptions=0)
        table.attach(gtk.Label('up'), 0, 1, 1, 2, xoptions=0, yoptions=0)

        self.xdownentry = gtk.Entry()
        self.ydownentry = gtk.Entry()
        self.xupentry = gtk.Entry()
        self.yupentry = gtk.Entry()
        gtklogger.setWidgetName(self.xdownentry, 'xdown')
        gtklogger.setWidgetName(self.ydownentry, 'ydown')
        gtklogger.setWidgetName(self.xupentry, 'xup')
        gtklogger.setWidgetName(self.yupentry, 'yup')  # yessirree, Bob!
        entries = [
            self.xdownentry, self.ydownentry, self.xupentry, self.yupentry
        ]
        if config.dimension() == 3:
            self.zdownentry = gtk.Entry()
            self.zupentry = gtk.Entry()
            gtklogger.setWidgetName(self.zdownentry, 'zdown')
            gtklogger.setWidgetName(self.zdownentry, 'zup')
            entries.append(self.zdownentry)
            entries.append(self.zupentry)
        self.entrychangedsignals = []
        for entry in entries:
            entry.set_size_request(12 * guitop.top().digitsize, -1)
            self.entrychangedsignals.append(
                gtklogger.connect(entry, "changed", self.poschanged))
        table.attach(self.xdownentry, 1, 2, 0, 1)
        table.attach(self.ydownentry, 2, 3, 0, 1)
        table.attach(self.xupentry, 1, 2, 1, 2)
        table.attach(self.yupentry, 2, 3, 1, 2)
        if config.dimension() == 3:
            table.attach(self.zdownentry, 3, 4, 0, 1)
            table.attach(self.zupentry, 3, 4, 1, 2)
        hbox = gtk.HBox(spacing=2)
        vbox.pack_start(hbox, expand=0, fill=0)
        self.prevmethodbutton = gtkutils.prevButton()
        self.repeatbutton = gtkutils.StockButton(gtk.STOCK_REFRESH, 'Repeat')
        gtklogger.setWidgetName(self.repeatbutton, 'Repeat')
        self.nextmethodbutton = gtkutils.nextButton()
        hbox.pack_start(self.prevmethodbutton, expand=0, fill=0)
        hbox.pack_start(self.repeatbutton, expand=1, fill=0)
        hbox.pack_start(self.nextmethodbutton, expand=0, fill=0)
        gtklogger.connect(self.repeatbutton, 'clicked', self.repeatCB)
        gtklogger.connect(self.repeatbutton, 'button-release-event',
                          self.repeateventCB)
        gtklogger.connect(self.prevmethodbutton, 'clicked',
                          self.historian.prevCB)
        gtklogger.connect(self.nextmethodbutton, 'clicked',
                          self.historian.nextCB)
        tooltips.set_tooltip_text(
            self.prevmethodbutton,
            "Recall the settings and mouse coordinates for the previous"
            " selection method.")
        tooltips.set_tooltip_text(
            self.nextmethodbutton,
            "Recall the settings and mouse coordinates for the next"
            " selection method.")
        tooltips.set_tooltip_text(
            self.repeatbutton,
            "Execute the selection method as if the mouse had been clicked"
            " at the above coordinates.  Hold the shift key to retain the"
            " previous selection.  Hold the control key to toggle the"
            " selection state of the selected pixels.")

        # Selection information
        hbox = gtk.HBox()
        outerbox.pack_start(hbox, expand=0, fill=0)
        hbox.pack_start(gtk.Label('Selection size: '), expand=0, fill=0)
        self.sizetext = gtk.Entry()
        gtklogger.setWidgetName(self.sizetext, 'size')
        hbox.pack_start(self.sizetext, expand=1, fill=1)
        self.sizetext.set_editable(False)
        self.sizetext.set_size_request(12 * guitop.top().digitsize, -1)
        self.setInfo()

        # switchboard callbacks
        self.sbcallbacks = [
            switchboard.requestCallbackMain(method,
                                            self.updateSelectionMethods),
            switchboard.requestCallback(
                (self.toolbox.gfxwindow(), 'layers changed'),
                self.setInfo_subthread)
        ]
示例#23
0
    def add(self, widget):
        widget_type = type(widget)
        print widget_type
        if (widget_type == Button or isinstance(widget, Button)):
            widget.controller = gtk.Button(widget.text)
            widget.controller.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)
            widget.controller.show()
            if (widget.callbackMethod != None):
                widget.controller.connect('clicked', widget.callbackMethod)

        elif (widget_type == TextArea or isinstance(widget, TextArea)):
            widget.controller = gtk.TextView(widget.buffer)
            widget.controller.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)
            widget.controller.show()
            if (widget.callbackMethod != None):
                widget.controller.connect('clicked', widget.callbackMethod)

        elif (widget_type == TextField or isinstance(widget, TextField)):
            widget.controller = gtk.Entry()
            widget.controller.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)
            widget.controller.set_text(widget.title)
            widget.controller.show()

        elif (widget_type == CheckBox or isinstance(widget, CheckBox)):
            widget.controller = gtk.CheckButton(widget.title)
            widget.controller.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)
            widget.controller.show()
            widget.controller.set_active(widget.value)

        elif (widget_type == RadioGroup or isinstance(widget, RadioGroup)):
            widget.controller = []
            radio_controller = gtk.RadioButton(None, widget.labels[0])
            radio_controller.set_size_request(widget.width, widget.height)
            self.fixed.put(radio_controller, widget.position_X[0],
                           widget.position_Y[0])
            radio_controller.show()
            widget.controller.append(radio_controller)
            for i in range(1, len(widget.labels)):
                radio_controller = gtk.RadioButton(widget.controller[0],
                                                   widget.labels[i])
                radio_controller.set_size_request(widget.width, widget.height)
                self.fixed.put(radio_controller, widget.position_X[i],
                               widget.position_Y[i])
                radio_controller.show()
                widget.controller.append(radio_controller)

            if (widget.selected_pos != None):
                widget.controller[widget.selected_pos].set_active(True)

        elif (widget_type == ValueList or isinstance(widget, ValueList)):
            widget.controller = gtk.OptionMenu()
            widget.controller.set_size_request(widget.width, widget.height)
            menu = gtk.Menu()
            for name in widget.choices:
                item = gtk.MenuItem(name)
                item.show()
                menu.append(item)
                print "gis"
            widget.controller.set_menu(menu)
            widget.controller.show()
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)

        elif (widget_type == LabelText or isinstance(widget, LabelText)):
            widget.controller = gtk.Label(widget.text)
            widget.controller.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)
            widget.controller.set_markup("<span font_desc='Calibri " +
                                         str(widget.size) + "'>" +
                                         widget.text + "</span>")
            widget.controller.show()

        elif (widget_type == Slider or isinstance(widget, Slider)):
            widget.controller = gtk.Adjustment(1.0, widget._from, widget._to,
                                               1.0, 1.0, 0.0)
            widget.scale = gtk.HScale(widget.controller)
            widget.scale.set_digits(0)
            widget.scale.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.scale, widget.position_X, widget.position_Y)
            widget.scale.show()

        elif (widget_type == Dialog or isinstance(widget, Dialog)):
            widget.title = widget.title
示例#24
0
    def __init__(self):
        qtwindow.QTWindow.__init__(self, 'data', _L('Data Browser'))
        self.connect("delete-event", self._delete_event_cb)

        self._browser = None
        self._meta_tags = set([])
        self._meta_tag = 'header'
        self._cur_path = None

        self._dir_entry = gtk.Entry()
        self._dir_entry.connect('activate', self._dir_activate_cb)
        self._dir_button = gtk.Button(_L('Browse'))
        self._dir_button.connect('clicked', self._dir_button_clicked_cb)
        self._dir_hbox = gui.pack_hbox(
            (gtk.Label('Directory'), self._dir_entry, self._dir_button), True,
            True)

        self._plot2d_button = gtk.Button(_L('Plot2D'))
        self._plot2d_button.connect('clicked', self._plot2d_clicked_cb)
        self._plot3d_button = gtk.Button(_L('Plot3D'))
        self._plot3d_button.connect('clicked', self._plot3d_clicked_cb)
        self._plot_name = gtk.Entry()
        self._plot_name.set_text('databrowser')
        self._plot_style = gtk.Entry()
        self._columns = gtk.Entry()
        self._clear_check = gtk.CheckButton()
        self._clear_check.set_active(True)
        self._clear_button = gtk.Button(_L('Clear'))
        self._clear_button.connect('clicked', self._clear_clicked_cb)
        self._ofs_entry = gtk.Entry()
        self._traceofs_entry = gtk.Entry()

        vbox1 = gui.pack_vbox([
            gui.pack_hbox([gtk.Label(_L('Name')), self._plot_name], False,
                          False),
            gui.pack_hbox([gtk.Label(_L('Clear')), self._clear_check], False,
                          False),
            gui.pack_hbox([gtk.Label(_L('Style')), self._plot_style], False,
                          False),
            gui.pack_hbox([gtk.Label(_L('Columns')), self._columns], False,
                          False),
        ], False, False)
        vbox2 = gui.pack_vbox([
            gui.pack_hbox([gtk.Label(_L('Offset')), self._ofs_entry], False,
                          False),
            gui.pack_hbox(
                [gtk.Label(_L('Trace offset')), self._traceofs_entry], False,
                False),
        ], False, False)

        self._plot_box = gui.pack_vbox([
            gui.pack_hbox([vbox1, vbox2], True, True),
            gui.pack_hbox(
                [self._plot2d_button, self._plot3d_button, self._clear_button],
                True, True),
        ], True, True)
        self._plot_box.set_border_width(4)
        self._plot_frame = gtk.Frame('Plot')
        self._plot_frame.add(self._plot_box)

        self._entries_model = gtk.ListStore(str)
        self._entries_model.set_sort_column_id(0, gtk.SORT_ASCENDING)
        self._entry_map = {}
        self._entries_view = qttable.QTTable([(_L('Filename'), {})], \
                self._entries_model)
        self._entries_view.connect('row-activated', self._row_activated_cb)
        self._entries_scroll = gtk.ScrolledWindow()
        self._entries_scroll.set_policy(gtk.POLICY_AUTOMATIC, \
                gtk.POLICY_AUTOMATIC)
        self._entries_scroll.add_with_viewport(self._entries_view)

        self._info_view = gtk.TextView()
        self._info_view.set_border_width(4)
        self._meta_dropdown = dropdowns.StringListDropdown([])
        self._meta_dropdown.connect('changed', self._meta_drop_changed_cb)
        self._info_box = gui.pack_vbox([self._meta_dropdown, self._info_view],
                                       False, False)
        self._info_box.set_border_width(4)

        self._views_hbox = gui.pack_hbox(
            (self._entries_scroll, self._info_box), True, True)

        vbox = gtk.VBox()
        vbox.pack_start(self._dir_hbox, False, False)
        vbox.pack_start(self._plot_frame, False, False)
        vbox.pack_start(self._views_hbox, True, True)
        self.add(vbox)

        vbox.show_all()
示例#25
0
    def createFlopTab(self):
        # hierarchy: hbox / ddbox     / ddhbox / Label + flop_games_cb | label + players_cb
        #                 / gamehbox / in_frame / table /
        #                            / out_frame

        tab_title = _("Flop")
        label = gtk.Label(tab_title)

        ddbox = gtk.VBox(False, 0)
        self.notebook.append_page(ddbox, label)

        ddhbox = gtk.HBox(False, 0)
        gamehbox = gtk.HBox(False, 0)

        ddbox.add(ddhbox)
        ddbox.add(gamehbox)

        # Combo boxes in the top row

        games = [
            "Holdem",
            "Omaha",
            "Omaha 8",
        ]
        players = ["2", "3", "4", "5", "6", "7", "8", "9", "10"]
        flop_games_cb = self.create_combo_box(games)
        players_cb = self.create_combo_box(players)

        label = gtk.Label(_("Gametype") + ":")
        ddhbox.add(label)
        ddhbox.add(flop_games_cb)
        label = gtk.Label(_("Players") + ":")
        ddhbox.add(label)
        ddhbox.add(players_cb)

        # Frames for Stove input and output

        in_frame = gtk.Frame(_("Input:"))
        out_frame = gtk.Frame(_("Output:"))

        gamehbox.add(in_frame)
        gamehbox.add(out_frame)

        self.outstring = """
No board given. Using Monte-Carlo simulation...
Enumerated 2053443 possible plays.
Your hand: (Ad Ac)
Against the range: {
                    AhAd, AhAs, AdAs, KhKd, KhKs, 
                    KhKc, KdKs, KdKc, KsKc, QhQd, 
                    QhQs, QhQc, QdQs, QdQc, QsQc, 
                    JhJd, JhJs, JhJc, JdJs, JdJc, 
                    JsJc
                   }

  Win       Lose       Tie
 69.91%    15.83%    14.26%

"""
        self.outputlabel = gtk.Label(self.outstring)
        out_frame.add(self.outputlabel)

        # Input Frame
        table = gtk.Table(4, 5, True)
        label = gtk.Label(_("Board:"))
        self.board = gtk.Entry()
        #self.board.connect("changed", self.set_board_flop, self.board)

        btn1 = gtk.Button()
        btn1.set_image(
            gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
        #btn.connect('clicked', self._some_function, arg)
        table.attach(label,
                     0,
                     1,
                     0,
                     1,
                     xoptions=gtk.SHRINK,
                     yoptions=gtk.SHRINK)
        table.attach(self.board,
                     1,
                     2,
                     0,
                     1,
                     xoptions=gtk.SHRINK,
                     yoptions=gtk.SHRINK)
        table.attach(btn1,
                     2,
                     3,
                     0,
                     1,
                     xoptions=gtk.SHRINK,
                     yoptions=gtk.SHRINK)

        label = gtk.Label(_("Player1:"))
        self.p1_board = gtk.Entry()
        #self.p1_board.connect("changed", self.set_hero_cards_flop, self.p1_board)
        btn2 = gtk.Button()
        btn2.set_image(
            gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
        #btn.connect('clicked', self._some_function, arg)
        btn3 = gtk.Button()
        btn3.set_image(
            gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
        #btn.connect('clicked', self._some_function, arg)
        table.attach(label,
                     0,
                     1,
                     1,
                     2,
                     xoptions=gtk.SHRINK,
                     yoptions=gtk.SHRINK)
        table.attach(self.p1_board,
                     1,
                     2,
                     1,
                     2,
                     xoptions=gtk.SHRINK,
                     yoptions=gtk.SHRINK)
        table.attach(btn2,
                     2,
                     3,
                     1,
                     2,
                     xoptions=gtk.SHRINK,
                     yoptions=gtk.SHRINK)
        table.attach(btn3,
                     3,
                     4,
                     1,
                     2,
                     xoptions=gtk.SHRINK,
                     yoptions=gtk.SHRINK)

        label = gtk.Label(_("Player2:"))
        self.p2_board = gtk.Entry()
        #self.p2_board.connect("changed", self.set_villain_cards_flop, self.p2_board)
        btn4 = gtk.Button()
        btn4.set_image(
            gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
        #btn.connect('clicked', self._some_function, arg)
        btn5 = gtk.Button()
        btn5.set_image(
            gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
        #btn.connect('clicked', self._some_function, arg)
        table.attach(label,
                     0,
                     1,
                     2,
                     3,
                     xoptions=gtk.SHRINK,
                     yoptions=gtk.SHRINK)
        table.attach(self.p2_board,
                     1,
                     2,
                     2,
                     3,
                     xoptions=gtk.SHRINK,
                     yoptions=gtk.SHRINK)
        table.attach(btn4,
                     2,
                     3,
                     2,
                     3,
                     xoptions=gtk.SHRINK,
                     yoptions=gtk.SHRINK)
        table.attach(btn5,
                     3,
                     4,
                     2,
                     3,
                     xoptions=gtk.SHRINK,
                     yoptions=gtk.SHRINK)

        btn6 = gtk.Button(_("Results"))
        btn6.connect("pressed", self.update_flop_output_pane, btn6)
        table.attach(btn6,
                     0,
                     1,
                     3,
                     4,
                     xoptions=gtk.SHRINK,
                     yoptions=gtk.SHRINK)

        in_frame.add(table)
示例#26
0
    def __init__(self, activity, channels):

        self._arduino_context_id = None

        gtk.Toolbar.__init__(self)
        self.activity = activity
        self._channels = channels

        self.mode = 'arduino'

        # Set up Sensores Button
        self.time = RadioToolButton(group=None)

        self.lista_sensores_button = []

        self.we_are_logging = False
        self._log_this_sample = False
        self._logging_timer = None
        self._logging_counter = 0
        self._image_counter = 0
        self._logging_interval = 0
        self._channels_logged = []
        self._busy = False
        self._take_screenshot = True

        log.debug('se agrega el boton refrescar')
        self.refrescar_button = RadioToolButton(group=None)
        self.refrescar_button.set_named_icon('recargar')
        self.refrescar_button.connect('clicked', self.click_refresh_button)
        self.insert(self.refrescar_button, -1)

        separator = gtk.SeparatorToolItem()
        separator.props.draw = True
        self.insert(separator, -1)

        self.robot = Arduino()

        self._port_entry = gtk.Entry()
        self._port_entry.set_text('A5')  # A
        self._port_entry_changed_id = self._port_entry.connect(
            'changed', self._read_sensor)
        if hasattr(self._port_entry, 'set_tooltip_text'):
            self._port_entry.set_tooltip_text(_('Enter a port to read.'))
        self._port_entry.set_width_chars(2)
        self._port_entry.show()
        toolitem = gtk.ToolItem()
        toolitem.add(self._port_entry)
        self.insert(toolitem, -1)
        toolitem.show()

        separator = gtk.SeparatorToolItem()
        separator.props.draw = True
        self.insert(separator, -1)

        self._log_value = LOG_TIMER_VALUES[1]
        self.log_label = gtk.Label(self._log_to_string(self._log_value))
        toolitem = gtk.ToolItem()
        toolitem.add(self.log_label)
        self.insert(toolitem, -1)

        self._log_button = ToolButton('timer-10')
        self._log_button.set_tooltip(_('Select logging interval'))
        self._log_button.connect('clicked', self._log_selection_cb)
        self.insert(self._log_button, -1)
        self._setup_log_palette()

        # Set up Logging/Stop Logging Button
        self._record = ToolButton('media-record')
        self.insert(self._record, -1)
        self._record.set_tooltip(_('Start Recording'))
        self._record.connect('clicked', self.record_control_cb)

        self.show_all()
示例#27
0
            self.reset_position(entry)


def manage_entry_position(entry):
    manager = PositionManager()
    entry.connect('focus-out-event', manager.focus_out)
    entry.connect('focus-in-event', manager.focus_in)
    entry.connect('changed', manager.changed)


if __name__ == '__main__':
    win = gtk.Window()
    win.set_title('Manage Entry Position')
    win.connect('delete-event', lambda *a: gtk.main_quit())
    vbox = gtk.VBox()
    win.add(vbox)

    entry1 = gtk.Entry()
    vbox.pack_start(entry1, expand=False, fill=False)
    manage_entry_position(entry1)
    entry1.set_text(string.ascii_letters)

    entry2 = gtk.Entry()
    entry2.set_alignment(1.0)
    vbox.pack_start(entry2, expand=False, fill=False)
    manage_entry_position(entry2)
    entry2.set_text(string.ascii_letters)

    win.show_all()
    gtk.main()
示例#28
0
    def __init__(self,
                 frame,
                 message="",
                 default_text='',
                 textview=None,
                 modal=True):

        gtk.Dialog.__init__(self)

        # Test if the signal is already binded since we do not clear it
        # when we destroy FindDialog
        if not gobject.signal_lookup("find-click", gtk.Window):
            gobject.signal_new("find-click", gtk.Window,
                               gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
                               (gobject.TYPE_STRING, ))

        self.textview = textview
        self.nicotine = frame

        self.connect("delete-event", self.quit)

        # The destroy event shoul clean up the reference to FindDialog
        # in the NicotineFrame object
        self.connect("destroy", self.destroy)

        self.nextPosition = None
        self.currentPosition = None
        self.lastdirection = "next"

        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, False, False)
            label.set_line_wrap(True)
            label.show()

        self.entry = gtk.Entry()

        box.pack_start(self.entry, False, False)
        self.entry.show()
        self.entry.grab_focus()
        self.entry.connect("activate", self.next)

        Cancelbutton = self.nicotine.CreateIconButton(gtk.STOCK_CANCEL,
                                                      "stock", self.quit,
                                                      _("Cancel"))
        Cancelbutton.set_flags(gtk.CAN_DEFAULT)
        self.action_area.pack_start(Cancelbutton)

        Previousbutton = self.nicotine.CreateIconButton(
            gtk.STOCK_GO_BACK, "stock", self.previous, _("Previous"))
        Previousbutton.set_flags(gtk.CAN_DEFAULT)
        self.action_area.pack_start(Previousbutton)

        Nextbutton = self.nicotine.CreateIconButton(gtk.STOCK_GO_FORWARD,
                                                    "stock", self.next,
                                                    _("Next"))
        Nextbutton.set_flags(gtk.CAN_DEFAULT)
        self.action_area.pack_start(Nextbutton)
        Nextbutton.grab_default()
示例#29
0
    def __init__(self, ip):

        TITLE = "Nmap Scan Module"
        nmap = getattr(config, 'NMAP_PATH')
        self.profiles = getattr(config, 'NMAP_PROFILES')
        self.ip = ip

        # Dialog
        self.dialog = gtk.Dialog(
            title=TITLE,
            parent=None,
            buttons=(gtk.STOCK_HELP, gtk.RESPONSE_HELP, gtk.STOCK_CANCEL,
                     gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
        self.dialog.resize(250, 75)

        # Label
        self.tglab = gtk.Label('Target:')
        self.tglab.set_alignment(0.0, 0.5)

        # A target text entry
        self.tgentry = gtk.Entry(max=50)
        self.tgentry.set_text(self.ip)

        # Label
        self.prolab = gtk.Label('Profile:')
        self.prolab.set_alignment(0.0, 0.5)

        # A ComboBox
        self.combobox = gtk.combo_box_new_text()
        for profile in self.profiles.keys():
            self.combobox.append_text(profile)
        self.combobox.connect('changed', self.changed_cb)

        # Label
        self.comlab = gtk.Label('Command:')
        self.comlab.set_alignment(0.0, 0.5)

        # A command text entry
        self.comentry = gtk.Entry(max=200)
        self.comentry.set_text('nmap -v -A ' + self.ip)

        # Separator
        self.sep = gtk.HSeparator()

        # ProgressBar
        self.progressbar = gtk.ProgressBar(adjustment=None)

        #########################################################
        # Table
        table = gtk.Table(rows=5, columns=4, homogeneous=False)
        table.set_row_spacings(2)
        table.set_col_spacings(2)

        # Add lements to Table
        table.attach(self.tglab, 0, 1, 0, 1)
        table.attach(self.tgentry, 1, 2, 0, 1)
        table.attach(self.prolab, 2, 3, 0, 1)
        table.attach(self.combobox, 3, 4, 0, 1)
        table.attach(self.comlab, 0, 1, 1, 2)
        table.attach(self.comentry, 1, 4, 1, 2)
        table.attach(self.sep, 1, 3, 2, 3)
        table.attach(self.progressbar, 0, 5, 3, 4)

        # Add HBox to VBox
        self.dialog.vbox.pack_start(table, False, False, 2)

        #########################################################
        # the help button
        self.butt_help = self.dialog.action_area.get_children()[2]
        self.butt_help.connect("clicked", lambda x: self.show_help())
        # the cancel button
        self.butt_cancel = self.dialog.action_area.get_children()[1]
        self.butt_cancel.connect("clicked", lambda x: self.dialog.destroy())

        # the save button
        self.butt_save = self.dialog.action_area.get_children()[0]
        self.butt_save.connect("clicked", self.validateData)

        # Check nmap availability
        if not os.path.exists(config.NMAP_PATH):
            self.progressbar.set_text('Nmap not found on: ' + config.NMAP_PATH)
            self.progressbar.set_fraction(1)
            self.butt_save.set_sensitive(False)

        # Finish
        self.dialog.show_all()
        self.dialog.show()
示例#30
0
    def _build_ui_tab(self, group):

        # The scrolled window
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.show()

        # Notebook tab
        tab = self._notebook.append_page(sw, gtk.Label(_(group.get_name())))

        # Settings table
        table = gtk.Table(len(group), 2, False)
        table.set_resize_mode(gtk.RESIZE_IMMEDIATE)
        table.show()
        sw.add_with_viewport(table)

        row = 0
        for element in group:
            if not isinstance(element, settings.RadioSetting):
                continue

            # Label
            label = gtk.Label(element.get_shortname() + ":")
            label.set_alignment(0.0, 0.5)
            label.show()

            table.attach(label, 0, 1, row, row + 1,
                         xoptions=gtk.FILL, yoptions=0,
                         xpadding=6, ypadding=3)

            if isinstance(element.value, list) and \
                    isinstance(element.value[0],
                               settings.RadioSettingValueInteger):
                box = gtk.HBox(True)
            else:
                box = gtk.VBox(True)

            # Widget container
            box.show()
            table.attach(box, 1, 2, row, row + 1,
                         xoptions=gtk.FILL, yoptions=0,
                         xpadding=12, ypadding=3)

            for i in element.keys():
                value = element[i]
                if isinstance(value, settings.RadioSettingValueInteger):
                    widget = gtk.SpinButton()
                    adj = widget.get_adjustment()
                    adj.configure(value.get_value(),
                                  value.get_min(), value.get_max(),
                                  value.get_step(), 1, 0)
                    widget.connect("value-changed", self._save_setting, value)
                elif isinstance(value, settings.RadioSettingValueFloat):
                    widget = gtk.Entry()
                    widget.set_width_chars(16)
                    widget.set_text(value.format())
                    widget.connect("focus-out-event", lambda w, e, v:
                                   self._save_setting(w, v), value)
                elif isinstance(value, settings.RadioSettingValueBoolean):
                    widget = gtk.CheckButton(_("Enabled"))
                    widget.set_active(value.get_value())
                    widget.connect("toggled", self._save_setting, value)
                elif isinstance(value, settings.RadioSettingValueList):
                    widget = miscwidgets.make_choice([], editable=False)
                    model = widget.get_model()
                    model.clear()
                    for option in value.get_options():
                        widget.append_text(option)
                    current = value.get_value()
                    index = value.get_options().index(current)
                    widget.set_active(index)
                    widget.connect("changed", self._save_setting, value)
                elif isinstance(value, settings.RadioSettingValueString):
                    widget = gtk.Entry()
                    widget.set_width_chars(32)
                    widget.set_text(str(value).rstrip())
                    widget.connect("focus-out-event", lambda w, e, v:
                                   self._save_setting(w, v), value)
                else:
                    LOG.error("Unsupported widget type: %s" % value.__class__)

                widget.set_sensitive(value.get_mutable())
                widget.show()

                box.pack_start(widget, 1, 1, 1)

            row += 1

        return tab