Esempio n. 1
0
    def __init__(self):
        self.dialog = gtk.Dialog(
            _("JACK Audio Manager"), None,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            (_("Close").encode('utf-8'), gtk.RESPONSE_CLOSE))

        start_up_label = gtk.Label(
            _("Start JACK output on application start-up"))

        self.startup_check_button = gtk.CheckButton()
        if editorpersistance.prefs.jack_start_up_op == appconsts.JACK_ON_START_UP_YES:
            self.startup_check_button.set_active(True)
        self.startup_check_button.connect("toggled",
                                          lambda w, e: start_op_changed(w),
                                          None)

        start_row = guiutils.get_checkbox_row_box(self.startup_check_button,
                                                  start_up_label)

        self.frequency_select = gtk.combo_box_new_text()
        cur_value_index = 0
        count = 0
        for freq in _jack_frequencies:
            self.frequency_select.append_text(str(freq))
            if freq == editorpersistance.prefs.jack_frequency:
                cur_value_index = count
            count = count + 1
        self.frequency_select.set_active(cur_value_index)
        self.frequency_select.connect(
            "changed", lambda w, e: frequency_changed(w.get_active()), None)

        freq_row = guiutils.get_two_column_box_right_pad(
            gtk.Label("JACK frequency Hz:"), self.frequency_select, 190, 15)

        self.output_type_select = gtk.combo_box_new_text()
        self.output_type_select.append_text(_("Audio"))
        self.output_type_select.append_text(_("Sync Master Timecode"))
        # Indexes correspond with appconsts.JACK_OUT_AUDIO, appconsts.JACK_OUT_SYNC values
        self.output_type_select.set_active(
            editorpersistance.prefs.jack_output_type)
        self.output_type_select.connect(
            "changed", lambda w, e: output_type_changed(w.get_active()), None)

        output_row = guiutils.get_two_column_box_right_pad(
            gtk.Label("JACK output type:"), self.output_type_select, 190, 15)

        vbox_props = gtk.VBox(False, 2)
        vbox_props.pack_start(freq_row, False, False, 0)
        vbox_props.pack_start(output_row, False, False, 0)
        vbox_props.pack_start(start_row, False, False, 0)
        vbox_props.pack_start(guiutils.pad_label(8, 12), False, False, 0)

        props_frame = guiutils.get_named_frame(_("Properties"), vbox_props)

        self.jack_output_status_value = gtk.Label("<b>OFF</b>")
        self.jack_output_status_value.set_use_markup(True)
        self.jack_output_status_label = gtk.Label("JACK output is ")
        status_row = guiutils.get_centered_box(
            [self.jack_output_status_label, self.jack_output_status_value])

        self.dont_use_button = gtk.Button(_("Stop JACK Output"))
        self.use_button = gtk.Button(_("Start JACK Output"))

        self.use_button.connect("clicked", lambda w: use_jack_clicked(self))
        self.dont_use_button.connect(
            "clicked", lambda w: _convert_to_original_media_project())

        self.set_gui_state()

        c_box_2 = gtk.HBox(True, 8)
        c_box_2.pack_start(self.dont_use_button, True, True, 0)
        c_box_2.pack_start(self.use_button, True, True, 0)

        row2_onoff = gtk.HBox(False, 2)
        row2_onoff.pack_start(gtk.Label(), True, True, 0)
        row2_onoff.pack_start(c_box_2, False, False, 0)
        row2_onoff.pack_start(gtk.Label(), True, True, 0)

        vbox_onoff = gtk.VBox(False, 2)
        vbox_onoff.pack_start(guiutils.pad_label(12, 4), False, False, 0)
        vbox_onoff.pack_start(status_row, False, False, 0)
        vbox_onoff.pack_start(guiutils.pad_label(12, 12), False, False, 0)
        vbox_onoff.pack_start(row2_onoff, False, False, 0)

        onoff_frame = guiutils.get_named_frame(_("Output Status"), vbox_onoff)

        # Pane
        vbox = gtk.VBox(False, 2)
        vbox.pack_start(props_frame, False, False, 0)
        vbox.pack_start(onoff_frame, False, False, 0)

        alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        alignment.set_padding(12, 12, 12, 12)
        alignment.add(vbox)

        self.dialog.vbox.pack_start(alignment, True, True, 0)
        dialogutils.default_behaviour(self.dialog)
        self.dialog.connect('response', dialogutils.dialog_destroy)
        self.dialog.show_all()

        global _dialog
        _dialog = self
Esempio n. 2
0
    def __init__(self, notebookinfo=None, port=8080, public=True, **opts):
        '''Constructor
		@param notebookinfo: the notebook location
		@param port: the http port to serve on
		@param public: allow connections to the server from other
		computers - if C{False} can only connect from localhost
		@param opts: options for L{WWWInterface.__init__()}
		'''
        gtk.Window.__init__(self)
        self.set_title('Zim - ' + _('Web Server'))  # T: Window title
        self.set_border_width(10)
        self.connect('destroy', lambda a: gtk.main_quit())
        self.interface_opts = opts
        self.httpd = None
        self._source_id = None

        # Widgets
        self.status_label = gtk.Label()
        self.status_label.set_markup('<i>' + _('Server not started') + '</i>')
        # T: Status in web server gui
        self.start_button = IconButton('gtk-media-play')
        self.start_button.connect('clicked', lambda o: self.start())
        self.stop_button = IconButton('gtk-media-stop')
        self.stop_button.connect('clicked', lambda o: self.stop())
        self.stop_button.set_sensitive(False)

        if gtk.gtk_version >= (2, 10):
            self.link_button = gtk.LinkButton('')
            self.link_button.set_sensitive(False)
        else:
            self.link_button = None

        self.notebookcombobox = NotebookComboBox(current=notebookinfo)
        self.open_button = IconButton('gtk-index')
        self.open_button.connect('clicked',
                                 lambda *a: NotebookDialog(self).run())

        self.portentry = gtk.SpinButton()
        self.portentry.set_numeric(True)
        self.portentry.set_range(80, 10000)
        self.portentry.set_increments(1, 80)
        self.portentry.set_value(port)

        self.public_checkbox = gtk.CheckButton(label=_('Allow public access'))
        # T: Checkbox in web server gui
        self.public_checkbox.set_active(public)

        # Build the interface
        vbox = gtk.VBox()
        self.add(vbox)

        hbox = gtk.HBox(spacing=12)
        hbox.pack_start(self.start_button, False)
        hbox.pack_start(self.stop_button, False)
        hbox.pack_start(self.status_label, False)
        vbox.add(hbox)

        table = input_table_factory((
            (_('Notebook'), self.notebookcombobox, self.open_button),
            # T: Field in web server gui
            (_('Port'), self.portentry),
            # T: Field in web server gui for HTTP port (e.g. port 80)
            self.public_checkbox))
        vbox.add(table)

        if self.link_button:
            hbox = gtk.HBox()
            hbox.pack_end(self.link_button, False)
            vbox.add(hbox)
Esempio n. 3
0
    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("WAVE MIXER")
        self.window.connect("destroy", self.destroy)
        self.window.set_size_request(1000, 800)
        self.fixed = gtk.Fixed()
        self.window.add(self.fixed)
        self.fixed.show()
        self.timerevlist = []
        self.modlist = []
        self.mixlist = []
        self.playing = [-1] * 3
        self.pause = [-1] * 3
        self.processpid = 0
        filelist = [-1] * 3
        self.mixspause = -1
        self.mixspid = -1
        self.modspause = -1
        self.modspid = -1
        for i in range(3):
            checkbutton1 = gtk.CheckButton("Time Reversal")
            checkbutton2 = gtk.CheckButton("Select for Modulation")
            checkbutton3 = gtk.CheckButton("Select for Mix")
            self.fixed.put(checkbutton1, 100 + 250 * i, 330)
            self.fixed.put(checkbutton2, 100 + 250 * i, 360)
            self.fixed.put(checkbutton3, 100 + 250 * i, 390)
            self.timerevlist.append(checkbutton1)
            self.modlist.append(checkbutton2)
            self.mixlist.append(checkbutton3)
    #scale for amplitude
        self.amplist = []
        for i in range(3):
            scale = gtk.HScale()
            scale.set_range(0, 10)
            scale.set_value(1)
            scale.set_increments(0.5, 1)
            scale.set_digits(1)
            scale.set_size_request(160, 45)
            self.fixed.put(scale, 100 + i * 250, 130)
            self.amplist.append(scale)
    #scale for time Shift
        self.timeshiftlist = []
        for i in range(3):
            scale = gtk.HScale()
            scale.set_range(-30, 30)
            scale.set_increments(1, 1)
            scale.set_digits(0)
            scale.set_size_request(160, 45)
            self.fixed.put(scale, 100 + i * 250, 200)
            self.timeshiftlist.append(scale)

    #scale for tCONTscaling
        self.timescalelist = []
        for i in range(3):
            scale = gtk.HScale()
            scale.set_range(0.125, 10)
            scale.set_value(1)
            scale.set_increments(0.125, 0.125)
            scale.set_digits(3)
            scale.set_size_request(160, 45)
            self.fixed.put(scale, 100 + i * 250, 270)
            self.timescalelist.append(scale)
        #filechooser
        self.filechooser = []
        for i in range(3):
            filechooserbutton = gtk.FileChooserButton("Select A File", None)
            filechooserbutton.connect("file-set", self.file_selected, i)
            filechooserbutton.set_width_chars(10)
            self.fixed.put(filechooserbutton, 100 + 250 * i, 50)
            self.filechooser.append(filechooserbutton)

        for i in range(3):
            label = gtk.Label("Select File")
            self.fixed.put(label, 120 + i * 250, 30)
        for i in range(3):
            label = gtk.Label("Amplitude:")
            self.fixed.put(label, 100 + i * 250, 110)
        for i in range(3):
            label = gtk.Label("Time Shift:")
            self.fixed.put(label, 100 + i * 250, 180)
        for i in range(3):
            label = gtk.Label("Time Scaling:")
            self.fixed.put(label, 100 + i * 250, 250)
        self.button = []
        for i in range(3):
            but = gtk.Button("Start")
            but1 = gtk.Button("Play/Pause")
            but2 = gtk.Button("Stop")
            self.button.append(but)
            self.fixed.put(but, 100 + i * 250, 500)
            self.fixed.put(but2, 240 + i * 250, 500)
            self.fixed.put(but1, 150 + i * 250, 500)
            but.connect("clicked", self.callback, i)
            but2.connect("clicked", self.stopback, i)
            but1.connect("clicked", self.pauseback, i)
        but = gtk.Button("Mix and Play")

        but3 = gtk.Button("Stop Mix")
        but2 = gtk.Button("Stop Modulation")
        but1 = gtk.Button("Modulate and Play")
        but.connect("clicked", self.mixback)
        but1.connect("clicked", self.modback)
        but2.connect("clicked", self.modstop)
        but3.connect("clicked", self.mixstop)
        self.fixed.put(but, 100, 600 - 50)
        self.fixed.put(but3, 100, 600 - 20)
        self.fixed.put(but1, 200, 600 - 50)
        self.fixed.put(but2, 200, 600 - 20)
        recordbut = gtk.Button("Record")
        recordbut.connect("clicked", self.recordstart)
        self.fixed.put(recordbut, 400, 550)
        #recordbut=gtk.Button("Play")
        #recordbut.connect("clicked",self.recordplay)
        self.recordingplay = -1
        self.recordpid = -1
        #self.fixed.put(recordbut,480,550)
        self.window.show_all()
Esempio n. 4
0
    def _init_ui(self):
        # Dialog for editing dimensions (width, height, DPI)
        app = self.app
        buttons = (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)
        self._size_dialog = windowing.Dialog(app,
                                             _("Frame Size"),
                                             app.drawWindow,
                                             buttons=buttons)
        unit = _('px')

        height_label = gtk.Label(_('Height:'))
        height_label.set_alignment(0.0, 0.5)
        width_label = gtk.Label(_('Width:'))
        width_label.set_alignment(0.0, 0.5)
        dpi_label = gtk.Label(_('Resolution:'))
        dpi_label.set_alignment(0.0, 0.5)
        color_label = gtk.Label(_('Color:'))
        color_label.set_alignment(0.0, 0.5)

        height_entry = gtk.SpinButton(adjustment=self.height_adj,
                                      climb_rate=0.25,
                                      digits=0)
        self.height_adj.set_spin_button(height_entry)

        width_entry = gtk.SpinButton(adjustment=self.width_adj,
                                     climb_rate=0.25,
                                     digits=0)
        self.width_adj.set_spin_button(width_entry)
        dpi_entry = gtk.SpinButton(adjustment=self.dpi_adj,
                                   climb_rate=0.0,
                                   digits=0)

        color_button = gtk.ColorButton()
        color_rgba = self.app.preferences.get("frame.color_rgba")
        color_rgba = [min(max(c, 0), 1) for c in color_rgba]
        color_gdk = RGBColor(*color_rgba[0:3]).to_gdk_color()
        color_alpha = int(65535 * color_rgba[3])
        color_button.set_color(color_gdk)
        color_button.set_use_alpha(True)
        color_button.set_alpha(color_alpha)
        color_button.set_title(_("Frame Color"))
        color_button.connect("color-set", self._color_set_cb)
        color_align = gtk.Alignment(0, 0.5, 0, 0)
        color_align.add(color_button)

        size_table = gtk.Table(6, 3)
        size_table.set_border_width(3)
        xopts = gtk.FILL | gtk.EXPAND
        yopts = gtk.FILL
        xpad = ypad = 3

        unit_combobox = gtk.ComboBoxText()
        for unit in UnitAdjustment.CONVERT_UNITS.keys():
            unit_combobox.append_text(unit)
        for i, key in enumerate(UnitAdjustment.CONVERT_UNITS):
            if key == _('px'):
                unit_combobox.set_active(i)
        unit_combobox.connect('changed', self.on_unit_changed)
        self._unit_combobox = unit_combobox

        row = 0
        size_table.attach(width_label, 0, 1, row, row + 1, xopts, yopts, xpad,
                          ypad)
        size_table.attach(width_entry, 1, 2, row, row + 1, xopts, yopts, xpad,
                          ypad)
        size_table.attach(self.unit_label, 2, 3, row, row + 1, xopts, yopts,
                          xpad + 4, ypad)

        row += 1
        size_table.attach(height_label, 0, 1, row, row + 1, xopts, yopts, xpad,
                          ypad)
        size_table.attach(height_entry, 1, 2, row, row + 1, xopts, yopts, xpad,
                          ypad)
        size_table.attach(unit_combobox, 2, 3, row, row + 1, xopts, yopts,
                          xpad, ypad)

        row += 1
        size_table.attach(dpi_label, 0, 1, row, row + 1, xopts, yopts, xpad,
                          ypad)
        size_table.attach(dpi_entry, 1, 2, row, row + 1, xopts, yopts, xpad,
                          ypad)

        # Options panel UI
        opts_table = gtk.Table(3, 3)
        opts_table.set_border_width(3)

        row = 0
        size_button = gtk.Button("<size-summary>")
        self._size_button = size_button
        size_button.connect("clicked", self._size_button_clicked_cb)
        opts_table.attach(size_button, 0, 2, row, row + 1, xopts, yopts, xpad,
                          ypad)

        row += 1
        opts_table.attach(color_label, 0, 1, row, row + 1, xopts, yopts, xpad,
                          ypad)
        opts_table.attach(color_align, 1, 2, row, row + 1, xopts, yopts, xpad,
                          ypad)

        crop_layer_button = gtk.Button(_('Set Frame to Layer'))
        crop_layer_button.set_tooltip_text(
            _("Set frame to the extents of "
              "the current layer"))
        crop_document_button = gtk.Button(_('Set Frame to Document'))
        crop_document_button.set_tooltip_text(
            _("Set frame to the combination "
              "of all layers"))
        crop_layer_button.connect('clicked', self.crop_frame_cb,
                                  'CropFrameToLayer')
        crop_document_button.connect('clicked', self.crop_frame_cb,
                                     'CropFrameToDocument')

        trim_button = gtk.Button()
        trim_action = self.app.find_action("TrimLayer")
        trim_button.set_related_action(trim_action)
        trim_button.set_label(_('Trim Layer to Frame'))
        trim_button.set_tooltip_text(
            _("Trim parts of the current layer "
              "which lie outside the frame"))

        self.enable_button = gtk.CheckButton()
        frame_toggle_action = self.app.find_action("FrameToggle")
        self.enable_button.set_related_action(frame_toggle_action)
        self.enable_button.set_label(_('Enabled'))

        row += 1
        opts_table.attach(self.enable_button, 1, 2, row, row + 1, xopts, yopts,
                          xpad, ypad)

        row += 1
        opts_table.attach(crop_layer_button, 0, 2, row, row + 1, xopts, yopts,
                          xpad, ypad)

        row += 1
        opts_table.attach(crop_document_button, 0, 2, row, row + 1, xopts,
                          yopts, xpad, ypad)

        row += 1
        opts_table.attach(trim_button, 0, 2, row, row + 1, xopts, yopts, xpad,
                          ypad)

        content_area = self._size_dialog.get_content_area()
        content_area.pack_start(size_table, True, True)

        self._size_dialog.connect('response', self._size_dialog_response_cb)

        self.add(opts_table)
Esempio n. 5
0
    def __init__(self):
        self.readlog = None
        self.keyList = None
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.set_resizable(True)
        window.set_size_request(1000, 800)
        window.connect("destroy", self.close_application)
        window.set_title("TextView Widget Basic Example")
        window.set_border_width(0)

        box1 = gtk.VBox(False, 0)
        window.add(box1)
        box1.show()

        box2 = gtk.VBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, True, True, 0)
        box2.show()

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        textview = gtk.TextView()
        self.textbuffer = textview.get_buffer()
        sw.add(textview)
        sw.show()
        textview.show()

        box2.pack_start(sw)
        #--- changes

        hbox = gtk.HButtonBox()
        box2.pack_start(hbox, False, False, 0)
        hbox.show()

        vbox = gtk.VBox()
        vbox.show()
        hbox.pack_start(vbox, False, False, 0)
        # check button to toggle editable mode
        check = gtk.CheckButton("Editable")
        vbox.pack_start(check, False, False, 0)
        check.connect("toggled", self.toggle_editable, textview)
        check.set_active(True)
        check.show()
        # check button to toggle cursor visiblity
        check = gtk.CheckButton("Cursor Visible")
        vbox.pack_start(check, False, False, 0)
        check.connect("toggled", self.toggle_cursor_visible, textview)
        check.set_active(True)
        check.show()
        # check button to toggle left margin
        check = gtk.CheckButton("Left Margin")
        vbox.pack_start(check, False, False, 0)
        check.connect("toggled", self.toggle_left_margin, textview)
        check.set_active(False)
        check.show()
        # check button to toggle right margin
        check = gtk.CheckButton("Right Margin")
        vbox.pack_start(check, False, False, 0)
        check.connect("toggled", self.toggle_right_margin, textview)
        check.set_active(False)
        check.show()
        # radio buttons to specify wrap mode
        vbox = gtk.VBox()
        vbox.show()
        hbox.pack_start(vbox, False, False, 0)
        radio = gtk.RadioButton(None, "WRAP__NONE")
        vbox.pack_start(radio, False, True, 0)
        radio.connect("toggled", self.new_wrap_mode, textview, gtk.WRAP_NONE)
        radio.set_active(True)
        radio.show()
        radio = gtk.RadioButton(radio, "WRAP__CHAR")
        vbox.pack_start(radio, False, True, 0)
        radio.connect("toggled", self.new_wrap_mode, textview, gtk.WRAP_CHAR)
        radio.show()
        radio = gtk.RadioButton(radio, "WRAP__WORD")
        vbox.pack_start(radio, False, True, 0)
        radio.connect("toggled", self.new_wrap_mode, textview, gtk.WRAP_WORD)
        radio.show()

        # radio buttons to specify justification
        vbox = gtk.VBox()
        vbox.show()
        hbox.pack_start(vbox, False, False, 0)
        radio = gtk.RadioButton(None, "JUSTIFY__LEFT")
        vbox.pack_start(radio, False, True, 0)
        radio.connect("toggled", self.new_justification, textview,
                      gtk.JUSTIFY_LEFT)
        radio.set_active(True)
        radio.show()
        radio = gtk.RadioButton(radio, "JUSTIFY__RIGHT")
        vbox.pack_start(radio, False, True, 0)
        radio.connect("toggled", self.new_justification, textview,
                      gtk.JUSTIFY_RIGHT)
        radio.show()
        radio = gtk.RadioButton(radio, "JUSTIFY__CENTER")
        vbox.pack_start(radio, False, True, 0)
        radio.connect("toggled", self.new_justification, textview,
                      gtk.JUSTIFY_CENTER)
        radio.show()

        separator = gtk.HSeparator()
        box1.pack_start(separator, False, True, 0)
        separator.show()

        box2 = gtk.VBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, False, True, 0)
        box2.show()

        button = gtk.Button("close")
        button.connect("clicked", self.close_application)
        box2.pack_start(button, True, True, 0)
        button.set_flags(gtk.CAN_DEFAULT)
        button.grab_default()
        button.show()
        window.show()

        #---------- Logic Buttons ---------
        #--
        label = gtk.Label("Log Path to Process")
        label.set_alignment(0, 0)
        vbox.pack_start(label, True, True, 0)
        label.show()

        self.entry = gtk.Entry()
        self.entry.set_max_length(100)
        self.entry.connect("activate", self.enter_callback, self.entry)
        self.entry.set_text(
            "/var/opt/ORCLemaas/var_opt_ORCLemaas/logs/loganalytics/library/libraryLog.log"
        )
        self.entry.insert_text("", len(self.entry.get_text()))
        self.entry.select_region(0, len(self.entry.get_text()))
        vbox.pack_start(self.entry, True, True, 0)
        self.entry.show()

        buttonlog = gtk.Button("Process log")
        buttonlog.connect("clicked", self.process_log, None)
        vbox.pack_start(buttonlog, True, True, 0)
        #buttonlog.set_flags(gtk.CAN_DEFAULT)
        #buttonlog.grab_default()
        buttonlog.show()
        buttonlog.show()

        buttonlogv = gtk.Button("View log")
        buttonlogv.connect("clicked", self.view_log, None)
        vbox.pack_start(buttonlogv, True, True, 0)
        #buttonlogv.set_flags(gtk.CAN_DEFAULT)
        #buttonlogv.grab_default()
        buttonlogv.show()
        buttonlogv.show()

        #--
        label = gtk.Label("Type of Category")
        label.set_alignment(0, 0)
        vbox.pack_start(label, True, True, 0)
        label.show()

        self.event_type_txt = gtk.Entry()
        self.event_type_txt.set_max_length(100)
        self.event_type_txt.connect("activate", self.enter_callback)
        self.event_type_txt.set_text("2")
        self.event_type_txt.insert_text("",
                                        len(self.event_type_txt.get_text()))
        self.event_type_txt.select_region(0,
                                          len(self.event_type_txt.get_text()))
        vbox.pack_start(self.event_type_txt, True, True, 0)
        self.event_type_txt.show()

        #--
        label = gtk.Label("Number of Lines")
        label.set_alignment(0, 0)
        vbox.pack_start(label, True, True, 0)
        label.show()

        self.num_rows_txt = gtk.Entry()
        self.num_rows_txt.set_max_length(100)
        self.num_rows_txt.connect("activate", self.enter_callback)
        self.num_rows_txt.set_text("4")
        self.num_rows_txt.insert_text("", len(self.num_rows_txt.get_text()))
        self.num_rows_txt.select_region(0, len(self.num_rows_txt.get_text()))
        vbox.pack_start(self.num_rows_txt, True, True, 0)
        self.num_rows_txt.show()

        button = gtk.Button("See latest event")
        button.connect("clicked", self.see_latest_event, None)
        vbox.pack_start(button, True, True, 0)
        #button.set_flags(gtk.CAN_DEFAULT)
        #button.grab_default()
        button.show()
        window.show()

        button2 = gtk.Button("See event one by one")
        button2.connect("clicked", self.see_event_onebyone, None)
        vbox.pack_start(button2, True, True, 0)
        #button2.set_flags(gtk.CAN_DEFAULT)
        #button2.grab_default()
        button2.show()
        window.show()

        # Load the file  into the text window
        #infile = open("textview-basic.py", "r")
        infile = open(self.entry.get_text(), "r")

        if infile:
            string = infile.read()
            infile.close()
            self.textbuffer.set_text(string)
Esempio n. 6
0
    def __init__(self, parent=None):
        """"""
        Dialog.__init__(self)
        self.set_title(_("Host Accounts"))
        self.set_size_request(500, 500)
        self.set_transient_for(parent)

        self.host_accounts = host_accounts  #instancia de clase Host_Accounts
        self.update_flag = False
        self.stop_update = False

        #Estructura-General:
        #-------------------vbox1_start---------------
        #-------------------hbox1_start---------------
        #-------------------frame2----------------------Accounts
        #-------------------hbox1_end----------------
        #-------------------hbox3_start--------------
        #-------------------frame3----------------------Login
        #-------------------hbox3_end----------------
        #-------------------hbox6-----------------------Exit-Buttons
        #-------------------vbox1_end----------------

        #Estructura-Accounts
        #-------------------frame2_start-------------
        #-------------------vbox3_start--------------
        #---------------------------------------------------ScrollWindow
        #-------------------hbox2-----------------------Buttons
        #-------------------vbox3_end----------------
        #-------------------frame2_end---------------

        #Estructura-Login
        #-------------------frame3_start-------------
        #-------------------vbox4_start--------------
        #-------------------hbox4_start--------------
        #-------------------vbox5-----------------------Label
        #-------------------vbox6-----------------------Entry
        #-------------------hbox4_end----------------
        #-------------------hbox5-----------------------Button
        #-------------------vbox4_end----------------
        #-------------------frame3_end---------------

        #containers-separators.
        #self.vbox no puede ser cambiado en gtk.Dialog. Crear variable vbox y luego meterla en self.vbox.
        vbox1 = gtk.VBox(
            False, 20
        )  #gtk.VBox(homogeneous=False, spacing=0) homogeneous: mismo espacio cada hijo, spacing: espacio vertical entre hijos.
        vbox1.set_border_width(10)  #outside-space

        #vbox1_start
        #hbox1_start
        #-------------------------------------------
        #containers-separators.
        hbox1 = gtk.HBox(False, 10)  #file field and button examine.
        #gtk.HBox(homogeneous=False, spacing=0) homogeneous: mismo espacio cada hijo, spacing: espacio horizontal entre hijos.

        #Accounts list
        #frame2
        frame2 = gtk.Frame(_("Accounts:"))

        #vbox3
        #containers-separators.
        vbox3 = gtk.VBox(False, 10)
        vbox3.set_border_width(10)  #outside-space
        hbox2 = gtk.HBox(False, 10)  #Buttons.

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

        self.store = gtk.ListStore(
            str, str, str, str, str,
            bool)  #modelo de columnas. (3 columnas de strings)

        #arma el cuadro con los items
        self.treeView = gtk.TreeView(self.store)
        self.treeView.set_rules_hint(True)  #turna el color de los items, creo.
        scroll.add(self.treeView)

        self.row_selected = None  #fila seleccionada, se cambia en el on_selected
        self.treeView.get_selection().connect(
            "changed", self.on_selected)  #item seleccionado

        #Columns item names.
        col_list = [
            "hidden_id_account",
            _("Host"),
            _("Status"),
            _("Username"),
            _("Password"),
            _("Enable")
        ]  #podria usar un frozenset, no se si lo soporta cython.
        self.create_columns(col_list)

        check_btn = gtk.CheckButton()
        check_btn.set_active(True)
        #check_btn.unset_flags(gtk.CAN_FOCUS)

        #self.store.append(["YES", "CRAP", "CRAP", "premium", False])

        vbox3.add(scroll)

        #hbox2
        self.button1 = gtk.Button(_("Remove"))
        self.button1.set_size_request(80, 35)
        self.button1.set_sensitive(False)
        self.button1.connect("clicked", self.on_remove)
        hbox2.add(self.button1)

        self.button2 = gtk.Button(_("Check"))
        self.button2.set_size_request(80, 35)
        self.button2.set_sensitive(False)
        self.button2.connect("clicked", self.on_check)
        hbox2.add(self.button2)

        halign1 = gtk.Alignment(1, 0, 0,
                                0)  #horizontal container. right liagment.
        #xalign: espacio libre a la izquierda del hijo. 0.0 = sin espacio arriba. 1.0 = todo el espacio arriba.
        #yalign: espacio libre vertical arriba del hijo. 0.0 = sin espacio arriba. 1.0 = todo el espacio arriba.
        halign1.add(hbox2)

        vbox3.pack_start(halign1, False)

        #Let's pack.
        frame2.add(vbox3)
        hbox1.add(frame2)
        vbox1.pack_start(hbox1)
        #vbox.pack_start(child, expand=True, fill=True, padding=0)
        #-------------------------------------------
        #hbox1_end

        #hbox3_start
        #-------------------------------------------
        #containers-separators.
        hbox3 = gtk.HBox(False, 10)  #buttons
        #gtk.HBox(homogeneous=False, spacing=0) homogeneous: mismo espacio cada hijo, spacing: espacio horizontal entre hijos.

        #Login fields
        #frame3
        frame3 = gtk.Frame(_("Login:"******"Server:"))
        label_server.set_alignment(
            0, 0.5)  #set_alignment(xalign, yalign), 0=left, 0.5=middle
        vbox5.add(label_server)
        label1 = gtk.Label(_("Username:"******"Password:"******"changed", self.on_changed")
        premium_services = [
            service
            for service, plugin_config in plugins_parser.services_dict.items()
            if plugin_config.get_premium_available()
        ]
        for service in sorted(premium_services):
            self.cb.append_text(service)
        self.cb.set_active(0)

        vbox6.add(self.cb)

        #entry...
        self.entry1 = gtk.Entry()
        self.entry1.add_events(gtk.gdk.KEY_RELEASE_MASK)
        self.entry1.set_width_chars(40)  #entry width

        vbox6.add(self.entry1)

        #entry...
        self.entry2 = gtk.Entry()
        self.entry2.add_events(gtk.gdk.KEY_RELEASE_MASK)
        self.entry2.set_width_chars(40)  #entry width

        vbox6.add(self.entry2)

        hbox4.add(vbox6)

        vbox4.add(hbox4)

        #hbox5
        button3 = gtk.Button(_("Add"))
        button3.set_size_request(80, 35)
        button3.connect("clicked", self.on_add)
        hbox5.add(button3)

        halign2 = gtk.Alignment(1, 0, 0,
                                0)  #horizontal container. right liagment.
        #xalign: espacio libre a la izquierda del hijo. 0.0 = sin espacio arriba. 1.0 = todo el espacio arriba.
        #yalign: espacio libre vertical arriba del hijo. 0.0 = sin espacio arriba. 1.0 = todo el espacio arriba.
        halign2.add(hbox5)

        vbox4.add(halign2)

        #Let's pack.
        frame3.add(vbox4)
        hbox3.add(frame3)
        vbox1.pack_start(hbox3, False)
        #vbox.pack_start(child, expand=True, fill=True, padding=0)
        #-------------------------------------------
        #hbox3_end

        #buttom.
        #-------------------------------------------
        #containers-separators.
        hbox6 = gtk.HBox(False, 10)  #buttons
        #gtk.HBox(homogeneous=False, spacing=0) homogeneous: mismo espacio cada hijo, spacing: espacio horizontal entre hijos.

        #hbox6
        button4 = gtk.Button(_("Cancel"))
        button4.set_size_request(80, 35)
        button4.connect("clicked", self.on_close)
        hbox6.add(button4)

        button5 = gtk.Button(_("Done"))
        button5.set_size_request(80, 35)
        button5.connect("clicked", self.on_done)
        hbox6.add(button5)

        halign3 = gtk.Alignment(1, 0, 0,
                                0)  #horizontal container. right liagment.
        #xalign: espacio libre a la izquierda del hijo. 0.0 = sin espacio arriba. 1.0 = todo el espacio arriba.
        #yalign: espacio libre vertical arriba del hijo. 0.0 = sin espacio arriba. 1.0 = todo el espacio arriba.
        halign3.set_padding(15, 0, 0,
                            0)  #set_padding(top, bottom, left, right)
        halign3.add(hbox6)

        vbox1.pack_start(halign3, False)
        #vbox.pack_start(child, expand=True, fill=True, padding=0)
        #-------------------------------------------
        #vbox1_end

        self.connect("response", self.on_close)
        self.vbox.pack_start(vbox1)

        #cargar cuentas.
        if self.cb.get_active_text() is not None:
            self.load_accounts()
        else:
            button3.set_sensitive(False)

        self.start_update()

        self.show_all()
        self.run()
Esempio n. 7
0
    def __init__(self, tree):

        # 7 rows and 3 columns
        gtk.Table.__init__(self, 7, 3)

        tree.connect('cursor-changed', self.cursor_changed)
        self.last_selected = None

        # Enabled checkbutton
        enabled_label = gtk.Label('Enabled:')
        self.enabled_field = enabled_checkbutton = gtk.CheckButton()
        enabled_checkbutton.set_tooltip_text(
            'If not checked, Definition won\'t be included in Saved Configuration.'
        )
        self.attach(enabled_label, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
        self.attach(enabled_checkbutton, 1, 3, 0, 1, yoptions=gtk.FILL)

        #Value Field
        value_label = gtk.Label('Value:')
        self.string_value_field = gtk.Entry()
        self.int_value_field = gtk.SpinButton()
        self.int_value_field.set_adjustment(gtk.Adjustment(0, 0, 2**32 - 1, 1))
        self.int_value_field.hide()
        self.bool_value_field = gtk.combo_box_new_text()
        self.bool_value_field.append_text('YES')
        self.bool_value_field.append_text('NO')
        self.bool_value_field.hide()
        value_box = gtk.VBox()
        value_box.add(self.string_value_field)
        value_box.add(self.int_value_field)
        value_box.add(self.bool_value_field)
        self.value_check_field = value_checkbutton = gtk.CheckButton()
        value_checkbutton.set_tooltip_text(
            'If not checked, Value won\'t be included in Saved Configuration.')
        value_checkbutton.set_active(True)

        self.attach(value_label, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
        self.attach(value_box, 1, 2, 1, 2, gtk.FILL, gtk.FILL)
        self.attach(value_checkbutton, 2, 3, 1, 2, gtk.FILL, gtk.FILL)

        # Add Sub-Definition button
        add_definition_button = gtk.Button('Add Sub-Definition')

        def add_sub_definition(button):
            model, selected = tree.get_selection().get_selected()
            if selected is not None:
                model.append(selected, (
                    '',
                    '',
                    False,
                    True,
                    '',
                    False,
                    {},
                ))
                self.value_check_field.set_active(False)  # auto disable value

        add_definition_button.connect('clicked', add_sub_definition)
        self.attach(add_definition_button, 0, 3, 2, 3, yoptions=gtk.FILL)

        # Remove Sub-Definition button
        remove_definition_button = gtk.Button('Remove Definition')

        def remove_definition(button):
            model, selected = tree.get_selection().get_selected()
            if selected is not None and not model[selected][2]:
                model.remove(selected)
                self.clear()

        remove_definition_button.connect('clicked', remove_definition)
        self.attach(remove_definition_button, 0, 3, 3, 4, yoptions=gtk.FILL)

        # Add/Remove Attribute Buttons
        add_attribute_button = gtk.Button('Add Attribute')
        remove_attribute_button = gtk.Button('Remove Attribute')
        button_table = gtk.Table(1, 3)
        add_attribute_button.connect(
            'clicked', lambda button: attributes_model.append((
                'var',
                '0',
            )))

        def remove_attribute(button):
            model, selected = attributes_list.get_selection().get_selected()
            if selected is not None:
                model.remove(selected)

        remove_attribute_button.connect('clicked', remove_attribute)
        button_table.attach(add_attribute_button, 0, 2, 0, 1)
        button_table.attach(remove_attribute_button, 2, 3, 0, 1)
        self.attach(button_table, 0, 3, 4, 5, yoptions=gtk.FILL)

        # Attributes TreeView
        attributes_label = gtk.Label('Attributes:')
        attributes_list = gtk.TreeView(
            gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING))
        attributes_scroll = gtk.ScrolledWindow()
        attributes_scroll.set_policy(gtk.POLICY_AUTOMATIC,
                                     gtk.POLICY_AUTOMATIC)
        attributes_scroll.set_shadow_type(gtk.SHADOW_OUT)
        attributes_scroll.set_border_width(5)
        attributes_scroll.add(attributes_list)
        self.attributes_field = attributes_model = attributes_list.get_model()

        def edited_handler(cell, path, text, data):
            model, col = data
            model[path][col] = text

        variable_column = gtk.TreeViewColumn('Variable')
        variable_column.set_min_width(gtk.gdk.Screen().get_width() / 11)
        variable_renderer = gtk.CellRendererText()
        variable_renderer.set_property('editable', True)
        variable_renderer.connect('edited', edited_handler, (
            attributes_model,
            0,
        ))
        variable_column.pack_start(variable_renderer)
        variable_column.add_attribute(variable_renderer, 'text', 0)

        value_column = gtk.TreeViewColumn('Value')
        value_renderer = gtk.CellRendererText()
        value_renderer.set_property('editable', True)
        value_renderer.connect('edited', edited_handler, (
            attributes_model,
            1,
        ))
        value_column.pack_start(value_renderer)
        value_column.add_attribute(value_renderer, 'text', 1)

        attributes_list.append_column(variable_column)
        attributes_list.append_column(value_column)
        self.attach(attributes_label, 0, 3, 5, 6, yoptions=gtk.FILL)
        self.attach(attributes_scroll, 0, 3, 6, 7)
Esempio n. 8
0
	def showSelect(self):
		selLabel=gtk.Label("Please select the test items")
		scrollWin=gtk.ScrolledWindow()
		scrollWin.set_size_request(300,400)
		scrollWin.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
		self.vbox.pack_start(selLabel, False,False, 20)
		store = gtk.ListStore(gobject.TYPE_STRING,
                                         gobject.TYPE_BOOLEAN,
					 gobject.TYPE_INT )
		self.con_db()
		self.get_type_from_db()
		self.typeNum = 0
		#self.get_kblayout()
                for item in self.alltype:
                	store.append((item[0], None, item[1]))
			self.typeNum += 1
				
		treeView = gtk.TreeView(store)
		cell2 = gtk.CellRendererToggle()
        	cell2.set_property('activatable', True)
       		cell2.connect( 'toggled', self.on_item_clicked, store)
	        cell1 = gtk.CellRendererText()
        	cell1.set_property( 'editable', False )
        	#cell1.connect( 'edited', self.col0_edited_cb, store )

		column1 = gtk.TreeViewColumn("Test type\t\t\t\t\t\t\t", cell1, text=0)
        	column2 = gtk.TreeViewColumn("\t\t\t\t\tSelect", cell2 )
        	column2.add_attribute( cell2, "active", 1)


		#cell.connect("toggled", self.on_item_clicked)
                treeView.append_column(column1)
                treeView.append_column(column2)
		treeView.columns_autosize()
		scrollWin.add(treeView)
		#select all
		self.chkAll = gtk.CheckButton("Check All")
		self.chkAll.set_active(False)
		self.chkAll.unset_flags(gtk.CAN_FOCUS)
		self.chkAll.connect("clicked", self.on_chkAll_clicked, store)
		#just all automatic test item
		self.chkOnlyAuto = gtk.CheckButton("Auto test all automatic items")
		self.chkOnlyAuto.set_active(False)
		self.chkOnlyAuto.unset_flags(gtk.CAN_FOCUS)
		self.chkOnlyAuto.connect("clicked", self.on_chkOnlyAuto_clicked, store)
		#total select label
		self.selMsgLabel = gtk.Label()
		hbox1 = gtk.HBox()
		hbox1.pack_end(self.selMsgLabel, False, False,5)	
		
		hbox2 = gtk.HBox()
		hbox2.pack_start(self.chkAll, False, False, 0)
		hbox2.pack_start(self.chkOnlyAuto, False, False, 30)

		#start button
		startBtn = gtk.Button("Start")
		startBtn.connect("clicked", self.start_test_clicked, store)
		startBtn.set_size_request(100, 30)
		startBtn.set_tooltip_text("Click me,start test")
		self.set_button_bg_color(startBtn, button_bg_color)
		hbox3 = gtk.HBox()
		hbox3.pack_start(startBtn, True, False, 0)
		startBtn.set_size_request(100, 30)
		treeView.set_rules_hint(True)
		self.vbox.pack_start(scrollWin, False,False, 2)
		self.vbox.pack_start(hbox1, False,False, 0)
		self.vbox.pack_start(hbox2, False,False, 20)
		self.vbox.pack_start(hbox3, False,False, 20)
Esempio n. 9
0
	def show_test_result(self):
		idLabel = gtk.Label("ID")
		itemLabel = gtk.Label("Test Item")
		rsLabel = gtk.Label("Result")
		self.rsVbox = gtk.VBox()
	        self.rs_buffer = gtk.TextBuffer()
                rsScrolledWin=gtk.ScrolledWindow()
                rsTextView = gtk.TextView(self.rs_buffer)
                rsTextView.set_editable(False)
                rsTextView.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(514, 5140, 5140))
                rsTextView.set_cursor_visible(False)
                rsTextView.set_wrap_mode (gtk.WRAP_CHAR)
                rsTextView.set_size_request(300, 490)
		rsScrolledWin.add(rsTextView)
		rsScrolledWin.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)

		rslist = self.get_all_result()	
		i = 0
		count = len(rslist[0])
		print "count============",count
		rsText=""
		while i < count:
			strid="".join("%-10s" % rslist[0][i])
			stritem="".join("%-80s" % rslist[1][i])
			#tmp=rsText+"".join("%-15.30s %-80.90s %20s\n" %(rslist[0][i], rslist[1][i], rslist[2][i]))	
			if str(rslist[2][i]).find("P") != -1:
				strrs="P"
			elif str(rslist[2][i]).find("F") != -1:
				strrs="Fail"
			else:
				strrs=""
			rsText = rsText + "".join("   %10s\t%5s\t\t%-80s\t\n" %(strid, strrs, stritem))
			i = i+1
	        self.rs_buffer.set_text(rsText)
		strSucc="  Congratulations!\n You have completed all the test items, the following is a summary of the test results.\n Click 'submit' to upload the result."
		succLabel = gtk.Label(strSucc)
		succLabel.set_line_wrap(True)
                #succLabel.set_wrap_mode (gtk.WRAP_CHAR);
		succLabel.modify_text(gtk.STATE_NORMAL,finish_text_color)
		fontdesc = pango.FontDescription("Purisa 10")
		succLabel.modify_font(fontdesc)
		attr = pango.AttrList()
                fg_color = pango.AttrForeground(6, 60000, 0, 0, 300)
		size = pango.AttrSize(15000, 0, 18)
		attr.insert(fg_color)
		attr.insert(size)
		succLabel.set_attributes(attr)
		succLabel.set_size_request(WIN_WIDTH-20, 60)

		hbox1 = gtk.HBox()
		hbox1.pack_start(succLabel,False,False, 5)

		hbox2 = gtk.HBox()
		hbox2.pack_start(idLabel,False,False, 20)
		hbox2.pack_start(rsLabel,False,False, 40)
		hbox2.pack_start(itemLabel,False,False, 40)
	
		hbox3 = gtk.HBox()
                submit_button = gtk.Button("Submit")
		submit_button.set_size_request(BTN_WIDTH,BTN_HEIGHT)
                submit_button.connect("clicked", self.on_submit_click)
                exit_button = gtk.Button("Exit")
		exit_button.set_size_request(BTN_WIDTH,BTN_HEIGHT)
                exit_button.connect("clicked", self.on_exit_click)
	
		self.saveCheck = gtk.CheckButton("Delete test results when exit.")
		self.saveCheck.set_active(False)

		#if need to show the tester
		config = ConfigParser.ConfigParser()
Esempio n. 10
0
    def __init__(self):

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.set_size_request(750, 650)
        self.window.set_title("Wave Mixer")
        self.window.connect("destroy", lambda w: gtk.main_quit())

        self.play1 = 0
        self.play2 = 0
        self.play3 = 0

        self.pid1 = 0
        self.pid2 = 0
        self.pid3 = 0
        self.pid4 = 0
        self.pid5 = 0
        self.pid6 = 0

        self.fixed = gtk.Fixed()
        self.window.add(self.fixed)
        self.fixed.show()

        self.filechooserbutton11 = gtk.FileChooserButton("Wave1", None)
        self.filechooserbutton11.set_size_request(150, 40)
        fil = gtk.FileFilter()
        fil.add_pattern("*.wav")
        self.filechooserbutton11.add_filter(fil)
        self.fixed.put(self.filechooserbutton11, 40, 50)
        self.filechooserbutton11.connect("file-set", self.get_file, 1)

        self.lable1 = gtk.Label("Amplitude")
        self.fixed.put(self.lable1, 40, 120)

        self.scale = gtk.HScale()
        self.scale.set_range(0, 5)
        self.scale.set_increments(0.1, 1)
        self.scale.set_digits(1)
        self.scale.set_value(1)
        self.scale.set_size_request(160, 45)
        self.fixed.put(self.scale, 40, 140)

        self.lable2 = gtk.Label("Time Shift")
        self.fixed.put(self.lable2, 40, 200)

        self.scale2 = gtk.HScale()
        self.scale2.set_range(-1, 1)
        self.scale2.set_increments(0.1, 1)
        self.scale2.set_digits(1)
        self.scale2.set_size_request(160, 45)
        self.fixed.put(self.scale2, 40, 220)

        self.lable3 = gtk.Label("Time Scaling")
        self.fixed.put(self.lable3, 40, 280)

        self.scale3 = gtk.HScale()
        self.scale3.set_range(0, 10)
        self.scale3.set_increments(0.125, 1)
        self.scale3.set_digits(3)
        self.scale3.set_size_request(160, 45)
        self.fixed.put(self.scale3, 40, 300)

        self.check1 = gtk.CheckButton(label=None, use_underline=True)
        self.fixed.put(self.check1, 40, 370)
        self.l1 = gtk.Label("Time Reversal")
        self.fixed.put(self.l1, 70, 372)

        self.check2 = gtk.CheckButton(label=None, use_underline=True)
        self.fixed.put(self.check2, 40, 400)
        self.l2 = gtk.Label("Select for Modulation")
        self.fixed.put(self.l2, 70, 402)

        self.check3 = gtk.CheckButton(label=None, use_underline=True)
        self.fixed.put(self.check3, 40, 430)
        self.l3 = gtk.Label("Select for Mixing")
        self.fixed.put(self.l3, 70, 432)

        self.progressbar1 = gtk.ProgressBar(adjustment=None)
        self.fixed.put(self.progressbar1, 60, 480)

        self.button11 = gtk.Button("Play")
        self.button11.connect("clicked", self.play, 1)
        self.fixed.put(self.button11, 50, 510)

        self.button12 = gtk.Button("Pause")
        self.button12.connect("clicked", self.pause, 1)
        self.fixed.put(self.button12, 110, 510)

        self.button20 = gtk.Button("Stop")
        self.button20.connect("clicked", self.stop, 1)
        self.fixed.put(self.button20, 180, 510)

        self.text = gtk.Entry(12)
        self.fixed.put(self.text, 60, 565)

        self.text = gtk.HScale()
        self.text.set_range(0, 30)
        self.text.set_increments(0.5, 1)
        self.text.set_digits(1)
        self.text.set_size_request(160, 45)
        self.fixed.put(self.text, 80, 555)

        self.inp = gtk.Label("Time")
        self.fixed.put(self.inp, 30, 570)

        self.window.show()
        self.filechooserbutton11.show()
        self.scale.show()
        self.lable1.show()
        self.scale2.show()
        self.lable2.show()
        self.scale3.show()
        self.lable3.show()
        self.check1.show()
        self.l1.show()
        self.check2.show()
        self.l2.show()
        self.check3.show()
        self.l3.show()
        self.progressbar1.show()
        self.button11.show()
        self.button12.show()
        self.button20.show()
        self.text.show()
        self.inp.show()

        self.filechooserbutton22 = gtk.FileChooserButton("Wave2", None)
        self.filechooserbutton22.set_size_request(150, 40)
        self.filechooserbutton22.add_filter(fil)
        self.fixed.put(self.filechooserbutton22, 280, 50)
        self.filechooserbutton22.connect("file-set", self.get_file, 2)

        self.lable21 = gtk.Label("Amplitude")
        self.fixed.put(self.lable21, 280, 120)

        self.scale21 = gtk.HScale()
        self.scale21.set_range(0, 5)
        self.scale21.set_increments(0.1, 1)
        self.scale21.set_digits(1)
        self.scale21.set_value(1)
        self.scale21.set_size_request(160, 45)
        self.fixed.put(self.scale21, 280, 140)

        self.lable22 = gtk.Label("Time Shift")
        self.fixed.put(self.lable22, 280, 200)

        self.scale22 = gtk.HScale()
        self.scale22.set_range(-1, 1)
        self.scale22.set_increments(0.1, 1)
        self.scale22.set_digits(1)
        self.scale22.set_size_request(160, 45)
        self.fixed.put(self.scale22, 280, 220)

        self.lable23 = gtk.Label("Time Scaling")
        self.fixed.put(self.lable23, 280, 280)

        self.scale23 = gtk.HScale()
        self.scale23.set_range(0, 10)
        self.scale23.set_increments(0.125, 1)
        self.scale23.set_digits(3)
        self.scale23.set_size_request(160, 45)
        self.fixed.put(self.scale23, 280, 300)

        self.check21 = gtk.CheckButton(label=None, use_underline=True)
        self.fixed.put(self.check21, 280, 370)
        self.l21 = gtk.Label("Time Reversal")
        self.fixed.put(self.l21, 310, 372)

        self.check22 = gtk.CheckButton(label=None, use_underline=True)
        self.fixed.put(self.check22, 280, 400)
        self.l22 = gtk.Label("Select for Modulation")
        self.fixed.put(self.l22, 310, 402)

        self.check23 = gtk.CheckButton(label=None, use_underline=True)
        self.fixed.put(self.check23, 280, 430)
        self.l23 = gtk.Label("Select for Mixing")
        self.fixed.put(self.l23, 310, 432)

        self.progressbar2 = gtk.ProgressBar(adjustment=None)
        self.fixed.put(self.progressbar2, 300, 480)

        self.button21 = gtk.Button("Play")
        self.button21.connect("clicked", self.play, 2)
        self.fixed.put(self.button21, 290, 510)

        self.button22 = gtk.Button("Pause")
        self.button22.connect("clicked", self.pause, 2)
        self.fixed.put(self.button22, 350, 510)

        self.button30 = gtk.Button("Stop")
        self.button30.connect("clicked", self.stop, 2)
        self.fixed.put(self.button30, 420, 510)

        self.filechooserbutton22.show()
        self.scale21.show()
        self.lable21.show()
        self.scale22.show()
        self.lable22.show()
        self.scale23.show()
        self.lable23.show()
        self.check21.show()
        self.l21.show()
        self.check22.show()
        self.l22.show()
        self.check23.show()
        self.l23.show()
        self.progressbar2.show()
        self.button21.show()
        self.button22.show()
        self.button30.show()

        self.filechooserbutton33 = gtk.FileChooserButton("Wave3", None)
        self.filechooserbutton33.set_size_request(150, 40)
        self.filechooserbutton33.add_filter(fil)
        self.fixed.put(self.filechooserbutton33, 520, 50)
        self.filechooserbutton33.connect("file-set", self.get_file, 3)

        self.lable31 = gtk.Label("Amplitude")
        self.fixed.put(self.lable31, 520, 120)

        self.scale31 = gtk.HScale()
        self.scale31.set_range(0, 5)
        self.scale31.set_increments(0.1, 1)
        self.scale31.set_digits(1)
        self.scale31.set_value(1)
        self.scale31.set_size_request(160, 45)
        self.fixed.put(self.scale31, 520, 140)

        self.lable32 = gtk.Label("Time Shift")
        self.fixed.put(self.lable32, 520, 200)

        self.scale32 = gtk.HScale()
        self.scale32.set_range(-1, 1)
        self.scale32.set_increments(0.1, 1)
        self.scale32.set_digits(1)
        self.scale32.set_size_request(160, 45)
        self.fixed.put(self.scale32, 520, 220)

        self.lable33 = gtk.Label("Time Scaling")
        self.fixed.put(self.lable33, 520, 280)

        self.scale33 = gtk.HScale()
        self.scale33.set_range(0, 10)
        self.scale33.set_increments(0.125, 1)
        self.scale33.set_digits(3)
        self.scale33.set_size_request(160, 45)
        self.fixed.put(self.scale33, 520, 300)

        self.check31 = gtk.CheckButton(label=None, use_underline=True)
        self.fixed.put(self.check31, 520, 370)
        self.l31 = gtk.Label("Time Reversal")
        self.fixed.put(self.l31, 550, 372)

        self.check32 = gtk.CheckButton(label=None, use_underline=True)
        self.fixed.put(self.check32, 520, 400)
        self.l32 = gtk.Label("Select for Modulation")
        self.fixed.put(self.l32, 552, 402)

        self.check33 = gtk.CheckButton(label=None, use_underline=True)
        self.fixed.put(self.check33, 520, 430)
        self.l33 = gtk.Label("Select for Mixing")
        self.fixed.put(self.l33, 550, 432)

        self.progressbar3 = gtk.ProgressBar(adjustment=None)
        self.fixed.put(self.progressbar3, 540, 480)

        self.button31 = gtk.Button("Play")
        self.button31.connect("clicked", self.play, 3)
        self.fixed.put(self.button31, 530, 510)

        self.button32 = gtk.Button("Pause")
        self.button32.connect("clicked", self.pause, 3)
        self.fixed.put(self.button32, 590, 510)

        self.button40 = gtk.Button("Stop")
        self.button40.connect("clicked", self.stop, 3)
        self.fixed.put(self.button40, 660, 510)

        self.filechooserbutton33.show()
        self.scale31.show()
        self.lable31.show()
        self.scale32.show()
        self.lable32.show()
        self.scale33.show()
        self.lable33.show()
        self.check31.show()
        self.l31.show()
        self.check32.show()
        self.l32.show()
        self.check33.show()
        self.l33.show()
        self.progressbar3.show()
        self.button31.show()
        self.button32.show()
        self.button40.show()

        self.progressbar4 = gtk.ProgressBar(adjustment=None)
        self.fixed.put(self.progressbar4, 305, 580)
        self.button4 = gtk.Button("Modulate and Play")
        self.button4.connect("clicked", self.do_modulate)
        self.fixed.put(self.button4, 310, 605)

        self.progressbar5 = gtk.ProgressBar(adjustment=None)
        self.fixed.put(self.progressbar5, 540, 580)
        self.button5 = gtk.Button("Mix and Play")
        self.button5.connect("clicked", self.do_mix)
        self.fixed.put(self.button5, 570, 605)

        self.button6 = gtk.Button("Record")
        self.button6.connect("clicked", self.record_it)
        self.fixed.put(self.button6, 130, 605)

        self.button7 = gtk.Button("Play")
        self.button7.connect("clicked", self.play_myrec)
        self.fixed.put(self.button7, 200, 605)

        self.progressbar4.show()
        self.progressbar5.show()
        self.button4.show()
        self.button5.show()
        self.button6.show()
Esempio n. 11
0
    def add(self, widget):
        WidgetName = type(widget)  #finding type of widget being added
        #print WidgetName
        if (WidgetName == Button):  #if added widget is button
            widget.controller = gtk.Button(
                widget.text)  #setting name for button
            widget.controller.set_size_request(
                widget.width, widget.height)  #setting the size of button
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)  #setting location for button
            widget.controller.show()  #showing the button
            if (widget.callbackMethod !=
                    None):  #setting callback method for button
                widget.controller.connect('clicked', widget.callbackMethod)

        elif (WidgetName == TextArea):  #if added widget is TextArea
            widget.controller = gtk.TextView(
                widget.buffer)  #setting buffer for the TextArea
            widget.controller.set_size_request(
                widget.width, widget.height)  #setting the size of TextArea
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)  #  setting location for TextArea
            widget.controller.show()  #showing the TextArea
            if (widget.callbackMethod != None):
                widget.controller.connect(
                    'clicked',
                    widget.callbackMethod)  #adding callback method to Textarea
        elif (WidgetName == TextLine):  #if widget added is TextLine
            widget.controller = gtk.Entry()  #setting a widget for TextLine
            widget.controller.set_size_request(
                widget.width, widget.height)  #setting the size of TextLine
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)  #  setting location for TextLine
            widget.controller.show()  #showing the TextLine

        elif (WidgetName == CheckBox):  #if widget added is CheckBox
            widget.controller = gtk.CheckButton(
                widget.title)  #setting name for CheckBox
            widget.controller.set_size_request(
                widget.width, widget.height)  #setting the size of CheckBox
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)  #setting location for CheckBox
            widget.controller.show()  #showing the CheckBox
            widget.controller.set_active(
                widget.value)  #activating the CheckBox
####
        elif (WidgetName == Password):  #if widget added is Password
            widget.controller = gtk.Entry()  #adding a TextLine for Password
            widget.controller.set_visibility(
                0)  #making the characters invisible
            widget.controller.set_size_request(
                widget.width, widget.height)  #setting the size of PassWord
            self.fixed.put(
                widget.controller, widget.position_X,
                widget.position_Y)  #setting the position of PassWord
            widget.controller.show()

        elif (WidgetName == Label):  #if widget added is Label
            widget.controller = gtk.Label(
                widget.text)  #getting a Label with widget.text
            widget.controller.set_size_request(
                widget.width, widget.height)  #setting the size of Label
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)  #setting the position of Label
            widget.controller.show()

###

        elif (WidgetName == RadioGroup):  #if widget added is RadioGroup
            widget.controller = []  #
            radio_controller = gtk.RadioButton(
                None, widget.labels[0])  #getting RadioButtons for the group
            radio_controller.set_size_request(
                widget.width, widget.height)  #setting the size of RadioGroup
            self.fixed.put(
                radio_controller, widget.position_X[0],
                widget.position_Y[0])  #setting the position of RadioGroup
            radio_controller.show()  #showing the RadioButton
            widget.controller.append(
                radio_controller)  #appending RadioButton to RadioController
            for i in range(
                    1, len(widget.labels)
            ):  #for adding the remaining RadioButtons we have used the same procedure
                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
            ):  #setting the position of the selected RadioButton if it is not NULL
                widget.controller[widget.selected_pos].set_active(True)

        elif (WidgetName == DropDownList):  #if widget added is DropDownList
            widget.controller = gtk.OptionMenu(
            )  #gettin an Option Menu for DropDownList
            widget.controller.set_size_request(
                widget.width, widget.height)  #setting the size of DropDownList
            menu = gtk.Menu()
            for name in widget.choices:  #adding  menus in the menubar
                item = gtk.MenuItem(name)  #
                item.show()  #showing the items added
                menu.append(item)  #appending item to the menu
            widget.controller.set_menu(menu)
            widget.controller.show()  #showing the OptionMenu
            self.fixed.put(
                widget.controller, widget.position_X,
                widget.position_Y)  #setting the position of DropDownList
Esempio n. 12
0
 def view_scale_check(self, view_scale):
     self.cb_view_scale = gtk.CheckButton('View scale of map')
     self.cb_view_scale.set_active(view_scale)
     return myFrame(' Map Scale ', self.cb_view_scale)
Esempio n. 13
0
 def cross_check_box(self, show_cross):
     self.cb_show_cross = gtk.CheckButton(
         'Show a "+" in the center of the map')
     self.cb_show_cross.set_active(show_cross)
     return myFrame(" Mark center of the map ", self.cb_show_cross)
Esempio n. 14
0
    def __init__(self, box, conf, ind):

        self.conf = conf
        self.ind = ind

        for key in settings:
            if not key in conf.launcher[ind]:
                conf.launcher[ind][key] = settings[key]

        optionbox = gtk.HBox(False, 0)
        optionbox.set_border_width(0)
        optionbox.set_spacing(10)

        self.show_label_checkbox = gtk.CheckButton('Show label')
        self.show_label_checkbox.set_active(conf.launcher[ind]['show_label'])

        adjustment = gtk.Adjustment(value=conf.launcher[ind]['icon_size'],
                                    lower=16,
                                    upper=128,
                                    step_incr=1,
                                    page_incr=8,
                                    page_size=0)
        self.icon_size = gtk.SpinButton(adjustment=adjustment,
                                        climb_rate=0.0,
                                        digits=0)
        self.icon_size.set_tooltip_text('icon size in pixel')

        label = gtk.Label('icon size')

        optionbox.pack_start(self.show_label_checkbox, False, False)
        optionbox.pack_end(self.icon_size, False, False)
        optionbox.pack_end(label, False, False)

        table = gtk.Table()
        ligne = 0

        cmd = {
            'lockscreen': ('Lock screen', 'system-lock-screen'),
            'logout': ('Log out', 'gnome-session-logout'),
            'hibernate': ('Hibernate', 'gnome-session-hibernate'),
            'suspend': ('Suspend', 'gnome-session-suspend'),
            'reboot': ('Reboot', 'gnome-session-reboot'),
            'shutdown': ('Shutdown', 'gnome-session-halt')
        }

        self.widget_cmd = {}

        for key in ('lockscreen', 'logout', 'reboot', 'shutdown', 'hibernate',
                    'suspend'):

            label = gtk.Label(cmd[key][0])
            label.set_alignment(0, 1)

            self.widget_cmd[key] = gtk.Entry()
            self.widget_cmd[key].set_width_chars(45)
            self.widget_cmd[key].set_text(conf.launcher[ind][key])

            table.attach(label, 0, 1, ligne, ligne + 1)
            ligne += 1
            table.attach(self.widget_cmd[key], 0, 1, ligne, ligne + 1)
            ligne += 1

        table.set_col_spacings(4)
        table.set_row_spacings(4)
        table.set_border_width(4)
        table.set_homogeneous(False)

        scrolled = gtk.ScrolledWindow()
        scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scrolled.add_with_viewport(table)

        box.pack_start(optionbox, False, False)
        #~ box.pack_start(gtk.HSeparator(), False, False)
        box.pack_start(scrolled, True, True)
Esempio n. 15
0
    def __init__(self, primary_text, v4l2_control = False,
            v4l2_auto_control = False):
        Palette.__init__(self, label=primary_text)

        vbox = gtk.VBox()
        self.set_content(vbox)
        vbox.show()

        if v4l2_control:
            self._query_control = v4l2.v4l2_queryctrl(v4l2_control)
            self._control = v4l2.v4l2_control(v4l2_control)

            ioctl(VD, v4l2.VIDIOC_QUERYCTRL, self._query_control)
            ioctl(VD, v4l2.VIDIOC_G_CTRL, self._control)

            _max = self._query_control.maximum
            _min = self._query_control.minimum

            if v4l2_control == v4l2.V4L2_CID_EXPOSURE:
                _min = 0
                _max = 512
            elif v4l2_control == v4l2.V4L2_CID_GAIN:
                _min = 0
                _max = 37
            elif v4l2_control == v4l2.V4L2_CID_CONTRAST:
                _min = 0
                _max = 127
            elif v4l2_control == v4l2.V4L2_CID_BRIGHTNESS:
                _min = 0
                _max = 255
            #elif v4l2_control == v4l2.V4L2_CID_NIGHT_MODE:
            #    _min = 0
            #    _max = 1

            self._adjustment = gtk.Adjustment(value=self._control.value,
                    lower=_min,
                    upper=_max,
                    step_incr=1, page_incr=1, page_size=0)

            self._hscale = gtk.HScale(self._adjustment)
            self._hscale.set_digits(0)
            self._hscale.set_draw_value(False)
            self._hscale.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
            vbox.add(self._hscale)
            self._hscale.show()

            self._adjustment_handler_id = \
                self._adjustment.connect('value_changed',
                                         self.__adjustment_changed_cb)

            if v4l2_auto_control:
                self._auto_query_control =\
                    v4l2.v4l2_queryctrl(v4l2_auto_control)
                self._auto_control = v4l2.v4l2_control(v4l2_auto_control)

                self._auto_button = gtk.CheckButton('Auto')
                self._auto_button.set_active(self._auto_control.value)
                self._auto_button.connect('toggled',
                        self.__auto_button_toggled_cb)
                vbox.add(self._auto_button)
                self._auto_button.show()

                if self._auto_control.value == True:
                    self._hscale.set_sensitive(False)

        vbox.show()
Esempio n. 16
0
	def CreateCheckBox(self, xPos, yPos, Title ):
		checkButton = gtk.CheckButton( label = Title )
		self.window.fixed.put(checkButton, xPos, yPos)
Esempio n. 17
0
    def __init__(self, w3af, initial_request=None):
        super(FuzzyRequests,
              self).__init__(w3af, "fuzzyreq", "w3af - Fuzzy Requests",
                             "Fuzzy_Requests")
        self.w3af = w3af
        self.historyItem = HistoryItem()
        mainhbox = gtk.HBox()

        # To store the responses
        self.responses = []

        # ---- left pane ----
        vbox = gtk.VBox()
        mainhbox.pack_start(vbox, False, False)

        # we create the buttons first, to pass them
        analyzBut = gtk.Button("Analyze")
        self.sendPlayBut = entries.SemiStockButton(
            "", gtk.STOCK_MEDIA_PLAY, "Sends the pending requests")
        self.sendStopBut = entries.SemiStockButton(
            "", gtk.STOCK_MEDIA_STOP, "Stops the request being sent")
        self.sSB_state = helpers.PropagateBuffer(
            self.sendStopBut.set_sensitive)
        self.sSB_state.change(self, False)

        # Fix content length checkbox
        self._fix_content_lengthCB = gtk.CheckButton(
            'Fix content length header')
        self._fix_content_lengthCB.set_active(True)
        self._fix_content_lengthCB.show()

        # request
        self.originalReq = RequestPart(
            self,
            w3af, [
                analyzBut.set_sensitive, self.sendPlayBut.set_sensitive,
                functools.partial(self.sSB_state.change, 'rRV')
            ],
            editable=True,
            widgname='fuzzyrequest')

        if initial_request is None:
            self.originalReq.show_raw(FUZZY_REQUEST_EXAMPLE, '')
        else:
            (initialUp, initialDn) = initial_request
            self.originalReq.show_raw(initialUp, initialDn)

        # Add the right button popup menu to the text widgets
        rawTextView = self.originalReq.get_view_by_id('HttpRawView')
        rawTextView.textView.connect("populate-popup", self._populate_popup)

        # help
        helplabel = gtk.Label()
        helplabel.set_selectable(True)
        helplabel.set_markup(FUZZY_HELP)
        self.originalReq.append_page(helplabel, gtk.Label("Syntax help"))
        helplabel.show()
        self.originalReq.show()
        vbox.pack_start(self.originalReq, True, True, padding=5)
        vbox.show()

        # the commands
        t = gtk.Table(2, 4)
        analyzBut.connect("clicked", self._analyze)
        t.attach(analyzBut, 0, 2, 0, 1)
        self.analyzefb = gtk.Label("0 requests")
        self.analyzefb.set_sensitive(False)
        t.attach(self.analyzefb, 2, 3, 0, 1)
        self.preview = gtk.CheckButton("Preview")
        t.attach(self.preview, 3, 4, 0, 1)
        self.sPB_signal = self.sendPlayBut.connect("clicked", self._send_start)
        t.attach(self.sendPlayBut, 0, 1, 1, 2)
        self.sendStopBut.connect("clicked", self._send_stop)
        t.attach(self.sendStopBut, 1, 2, 1, 2)
        self.sendfb = gtk.Label("0 ok, 0 errors")
        self.sendfb.set_sensitive(False)
        t.attach(self.sendfb, 2, 3, 1, 2)
        t.attach(self._fix_content_lengthCB, 3, 4, 1, 2)
        t.show_all()

        vbox.pack_start(t, False, False, padding=5)

        # ---- throbber pane ----
        vbox = gtk.VBox()
        self.throbber = helpers.Throbber()
        self.throbber.set_sensitive(False)
        vbox.pack_start(self.throbber, False, False)
        vbox.show()
        mainhbox.pack_start(vbox, False, False)

        # ---- right pane ----
        vbox = gtk.VBox()
        mainhbox.pack_start(vbox)

        # A label to show the id of the response
        self.title0 = gtk.Label()
        self.title0.show()
        vbox.pack_start(self.title0, False, True)

        # result itself
        self.resultReqResp = ReqResViewer(w3af,
                                          withFuzzy=False,
                                          editableRequest=False,
                                          editableResponse=False)
        self.resultReqResp.set_sensitive(False)
        vbox.pack_start(self.resultReqResp, True, True, padding=5)
        vbox.show()

        # result control
        centerbox = gtk.HBox()
        self.pagesControl = entries.PagesControl(w3af, self.page_change)
        centerbox.pack_start(self.pagesControl, True, False)
        centerbox.show()

        # cluster responses button
        image = gtk.Image()
        image.set_from_file(
            os.path.join(ROOT_PATH, 'core', 'ui', 'gui', 'data',
                         'cluster_data.png'))
        image.show()
        self.clusterButton = gtk.Button(label='Cluster responses')
        self.clusterButton.connect("clicked", self._clusterData)
        self.clusterButton.set_sensitive(False)
        self.clusterButton.set_image(image)
        self.clusterButton.show()
        centerbox.pack_start(self.clusterButton, True, False)

        # clear responses button
        self.clearButton = entries.SemiStockButton(
            'Clear Responses',
            gtk.STOCK_CLEAR,
            tooltip='Clear all HTTP responses from fuzzer window')
        self.clearButton.connect("clicked", self._clearResponses)
        self.clearButton.set_sensitive(False)
        self.clearButton.show()
        centerbox.pack_start(self.clearButton, True, False)

        vbox.pack_start(centerbox, False, False, padding=5)

        # Show all!
        self._sendPaused = True
        self.vbox.pack_start(mainhbox)
        self.vbox.show()
        mainhbox.show()
        self.show()
Esempio n. 18
0
    def fill_widgets(self):
        # themes
        for i in self.templates:
            self.widgets['combo_theme'].insert_text(i,
                                                    self.templates[i]['name'])

        # sortby combo
        keys = self.names.keys()
        keys.sort()
        j = 0
        pos_o_title = 0
        for i in keys:
            self.widgets['combo_sortby'].append_text(i)
            if self.names[i] == self.settings['sorting']:
                pos_o_title = j
            j = j + 1
        self.widgets['combo_sortby'].set_wrap_width(3)

        # include data
        j = 0
        k = math.ceil(len(self.names) / float(3))
        for i in keys:
            j = j + 1
            field = self.names[i]
            self.widgets['cb_' + field] = gtk.CheckButton(i)
            self.widgets['cb_' + field].set_name("cb_%s" % field)
            self.widgets['cb_' + field].connect('toggled',
                                                self.on_cb_data_toggled)
            self.widgets['cb_' + field].set_active(self.fields[field])
            if j <= k:
                self.widgets['box_include_1'].add(self.widgets["cb_%s" %
                                                               field])
            elif j <= 2 * k:
                self.widgets['box_include_2'].add(self.widgets["cb_%s" %
                                                               field])
            else:
                self.widgets['box_include_3'].add(self.widgets["cb_%s" %
                                                               field])
        self.widgets['box_include_1'].show_all()
        self.widgets['box_include_2'].show_all()
        self.widgets['box_include_3'].show_all()

        # set defaults --------------------------------
        self.widgets['entry_header'].set_text(self.settings['title'])
        self.widgets['combo_sortby'].set_active(pos_o_title)
        if self.settings['sorting2'] == 'DESC':
            self.widgets['cb_reverse'].set_active(True)
        else:
            self.widgets['cb_reverse'].set_active(False)
        # template and theme
        style = self.settings[
            'style']  # save it temporary because change of the template set it 0
        self.widgets['combo_theme'].set_active(self.settings['template'])
        self.widgets['combo_style'].set_active(style)
        self.widgets['cb_custom_style'].set_active(
            self.settings['custom_style'])
        if self.settings['custom_style_file']:
            self.widgets['fcb_custom_style_file'].set_filename(
                self.settings['custom_style_file'])
        # spliting
        self.widgets['sb_split_num'].set_value(self.settings['split_num'])
        if self.settings['split_by'] == 0:
            self.widgets['rb_split_files'].set_active(True)
        else:
            self.widgets['rb_split_movies'].set_active(True)
        # posters
        self.widgets['combo_format'].set_active(0)
        if self.settings['poster_format'] == 'PNG':
            self.widgets['combo_format'].set_active(1)
        elif self.settings['poster_format'] == 'GIF':
            self.widgets['combo_format'].set_active(2)
        if self.settings['poster_convert'] and self.settings[
                'poster_convert'] == True:
            self.widgets['cb_convert'].set_active(True)
            self.widgets['vb_posters'].set_sensitive(True)
        else:
            self.widgets['cb_convert'].set_active(False)
            self.widgets['vb_posters'].set_sensitive(False)
        self.widgets['sb_height'].set_value(self.settings['poster_height'])
        self.widgets['sb_width'].set_value(self.settings['poster_width'])
        if self.settings['poster_mode'] == 'L':
            self.widgets['cb_black'].set_active(True)
        # destination dir
        if self.settings['export_dir']:
            self.widgets['fcw'].set_current_folder(self.settings['export_dir'])
Esempio n. 19
0
def find(self, self2):

    self.treestore = None

    dialog = gtk.Dialog("pyedit: Find in text", None,
                        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                        (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK,
                         gtk.RESPONSE_ACCEPT))
    dialog.set_default_response(gtk.RESPONSE_ACCEPT)

    # Spacers
    label1 = gtk.Label("   ")
    label2 = gtk.Label("   ")
    label3 = gtk.Label("   ")
    label4 = gtk.Label("   ")
    label5 = gtk.Label("   ")
    label6 = gtk.Label("   ")
    label7 = gtk.Label("   ")
    label8 = gtk.Label("   ")

    entry = gtk.Entry()
    entry.set_activates_default(True)
    entry.set_text(self2.oldsearch)
    dialog.vbox.pack_start(label4)

    hbox2 = gtk.HBox()
    hbox2.pack_start(label6, False)
    hbox2.pack_start(entry)
    hbox2.pack_start(label7, False)

    dialog.vbox.pack_start(hbox2)

    checkbox = gtk.CheckButton("Use _regular expressions")
    checkbox2 = gtk.CheckButton("Case In_sensitive")
    dialog.vbox.pack_start(label5)

    hbox = gtk.HBox()
    hbox.pack_start(label1)
    hbox.pack_start(checkbox)
    hbox.pack_start(label2)
    hbox.pack_start(checkbox2)
    hbox.pack_start(label3)
    dialog.vbox.pack_start(hbox)
    dialog.vbox.pack_start(label8)

    #label1.show(); label2.show();  label3.show();
    #hbox.show(); checkbox.show(); checkbox2.show(); entry.show()
    dialog.show_all()
    response = dialog.run()
    self2.oldsearch = entry.get_text()
    self.srctxt = entry.get_text()
    dialog.destroy()

    if response == gtk.RESPONSE_ACCEPT:
        #print "search", "'" + self.srctxt + "'"
        #print "checkbox", checkbox.get_active()
        #print "checkbox2", checkbox2.get_active()

        if self.srctxt == "":
            self2.mained.update_statusbar("Must specify search string")
            return

        self.peddoc = self2
        win2 = gtk.Window()
        win2.set_position(gtk.WIN_POS_CENTER)

        win2.set_events(gtk.gdk.POINTER_MOTION_MASK
                        | gtk.gdk.POINTER_MOTION_HINT_MASK
                        | gtk.gdk.BUTTON_PRESS_MASK
                        | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.KEY_PRESS_MASK
                        | gtk.gdk.KEY_RELEASE_MASK | gtk.gdk.FOCUS_CHANGE_MASK)

        win2.connect("key-press-event", area_key, self)
        win2.connect("key-release-event", area_key, self)

        # Position it out of the way
        sxx, syy = self2.mained.window.get_position()
        wxx, wyy = self2.mained.window.get_size()
        #print sxx, syy, wxx, wyy

        myww = 2 * wxx / 4
        myhh = 2 * wyy / 4
        win2.set_default_size(myww, myhh)
        win2.move(sxx + wxx - myww - 25, syy + 25)

        vbox = gtk.VBox()
        self.tree = create_tree(self, self.srctxt)
        self.tree.connect("row-activated", tree_sel, self)
        self.tree.connect("cursor-changed", tree_sel_row, self)

        stree = gtk.ScrolledWindow()
        stree.add(self.tree)
        vbox.pack_start(stree)
        win2.add(vbox)
        win2.show_all()

        accum = []
        cnt = 0
        cnt2 = 0
        was = -1
        curr = self2.caret[1] + self2.ypos

        if checkbox.get_active():
            regex = re.compile(self.srctxt)

        for line in self2.text:
            if checkbox2.get_active():
                #print "case search"
                idx = line.lower().find(self.srctxt.lower())
            elif checkbox.get_active():
                res = regex.search(line)
                if res:
                    idx = res.start()
                else:
                    cnt += 1
                    # Cont would skip this
                    continue
            else:
                idx = line.find(self.srctxt)

            if idx >= 0:
                if cnt > curr and was == -1:
                    #accum.append("curr");
                    was = cnt2
                line2 = str(idx) + ":" + str(cnt) + " " + line
                cnt2 += 1
                accum.append(line2)
            cnt += 1

        update_treestore(self, accum, was)

        #aa, bb, cc, dd = tree.get_path_at_pos(0, 0)
        #tree.set_cursor(aa)
        #print tree.get_cursor()
        self.tree.grab_focus()
Esempio n. 20
0
    def __init__(self, mainframe, service_data):
        '''
        Instantiates a user interface frame for uploading to a particular web service
        mainframe - the main application frame
        service_class - the class derived from ServiceBase implementing the service specific details.
        '''
        gtk.VBox.__init__(self)

        def vbox_group(widgets):
            box = gtk.VBox()
            for w in widgets:
                box.pack_start(*w)
            return box

        def hbox_group(widgets):
            box = gtk.HBox()
            for w in widgets:
                box.pack_start(*w)
            return box

        self.service_pref_box = gtk.VBox(
        )  ##the service should add service specific image preferences to this box
        self.mainframe = mainframe
        self.pref_change_handlers = []
        smod = __import__('picty.plugins.webupload_services.' +
                          service_data[2],
                          fromlist=[service_data[3]])
        self.service = getattr(smod, service_data[3])(
            self)  ##todo: handle import errors in the plugin

        self.login_status = gtk.Label(
            "Not connected"
        )  ##display "connected as <username>" once logged in
        self.login_button = gtk.Button(
            "Login ...")  ##display "change login" if connected already
        self.login_button.connect("clicked", self.cb_login_button)

        self.album_label = gtk.Label("Album")
        self.album_model = gtk.ListStore(str, gobject.TYPE_PYOBJECT)
        self.album_combo_entry = gtk.ComboBoxEntry(self.album_model, 0)
        #self.album_combo_entry=gtk.ComboBox(self.album_model)

        self.use_tags_check = gtk.CheckButton("Upload tags")
        self.resize_label = gtk.Label("Resize to (max width x max height)")
        self.resize_entry = gtk.Entry()
        self.strip_metadata_check = gtk.CheckButton("Strip metadata")

        self.upload_queue = UploadQueue(mainframe.tm,
                                        self.service.get_pref_types(),
                                        self.get_default_service_cols)
        self.service_box = gtk.VBox()

        self.start_stop_button = gtk.Button("Start _Upload")
        self.start_stop_button.connect("clicked", self.cb_start_stop_button)
        self.empty_button = gtk.Button("_Empty Queue")
        self.empty_button.connect("clicked", self.cb_empty_button)
        self.clean_up_button = gtk.Button("_Clean Up")
        self.clean_up_button.connect("clicked", self.cb_clean_up_button)
        self.select_all_button = gtk.Button("Select _All")
        self.select_all_button.connect("clicked", self.cb_select_all_button)
        self.select_none_button = gtk.Button("Select _None")
        self.select_none_button.connect("clicked", self.cb_select_none_button)

        self.login_box = hbox_group([(self.login_status, False),
                                     (self.login_button, True, False)])
        self.pack_start(self.login_box, False)
        self.pack_start(self.upload_queue, True)
        self.pack_start(
            hbox_group([(self.start_stop_button, False),
                        (self.empty_button, False),
                        (self.clean_up_button, False),
                        (self.select_all_button, False),
                        (self.select_none_button, False)]), False)
        self.pref_box = vbox_group(((hbox_group([
            (self.album_label, False), (self.album_combo_entry, True)
        ]), False), (hbox_group([(self.resize_label, False),
                                 (self.resize_entry, False)]),
                     False), (self.strip_metadata_check, False),
                                    (self.service_pref_box, False)))
        self.pack_start(self.pref_box, False)

        self.upload_queue.tv.get_selection().connect("changed",
                                                     self.selection_changed)
        self.pref_change_handlers.append(
            (self.resize_entry,
             self.resize_entry.connect("changed", self.resize_entry_changed)))
        self.pref_change_handlers.append(
            (self.strip_metadata_check,
             self.strip_metadata_check.connect(
                 "toggled", self.strip_metadata_check_toggled)))
        self.pref_change_handlers.append((self.album_combo_entry,
                                          self.album_combo_entry.child.connect(
                                              "changed",
                                              self.album_combo_entry_changed)))

        self.pref_box.set_sensitive(False)

        #        self.settings_box.set_sensitive(False)
        #        self.service_box.set_sensitive(False)
        self.logged_in = False
        self.started = False
        self.start_stop_button.set_sensitive(False)

        self.show_all()
Esempio n. 21
0
def find(self, self2, replace = False):

    self.treestore = None
    self.reptxt = ""
        
    if replace:
        head = "pyedit: Find / Replace"
    else:
        head = "pyedit: Find in text"
    
    dialog = gtk.Dialog(head,
                   None,
                   gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                   (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                    gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
    dialog.set_default_response(gtk.RESPONSE_ACCEPT)
    dialog.replace = replace
    dialog.set_icon_from_file(get_img_path("pyedit_sub.png"))
    self.dialog = dialog
    
    # Spacers
    label1 = gtk.Label("   ");  label2 = gtk.Label("   ") 
    label3 = gtk.Label("   ");  label4 = gtk.Label("   ") 
    label5 = gtk.Label("   ");  label6 = gtk.Label("   ") 
    label7 = gtk.Label("   ");  label8 = gtk.Label("   ") 

    entry = gtk.Entry(); entry.set_activates_default(True)
    
    if  self2.oldsearch == "":
            self2.oldsearch = gconf.client_get_default().\
                    get_string(config_reg + "/src")
            if  self2.oldsearch == None:
                self2.oldsearch = ""

    if  self2.oldrep == "":
            self2.oldrep = gconf.client_get_default().\
                    get_string(config_reg + "/rep")
            if  self2.oldrep == None:
                self2.oldrep = ""
    
    # See if we have a selection for search
    if self2.xsel != -1:
        xssel = min(self2.xsel, self2.xsel2)
        xesel = max(self2.xsel, self2.xsel2)
        yssel = min(self2.ysel, self2.ysel2)
        yesel = max(self2.ysel, self2.ysel2)

        if yssel == yesel:
            self2.oldsearch = self2.text[yssel][xssel:xesel]
            
    entry.set_text(self2.oldsearch)
    dialog.vbox.pack_start(label4)  

    hbox2 = gtk.HBox()
    hbox2.pack_start(label6, False)  
    hbox2.pack_start(entry)  
    hbox2.pack_start(label7, False)  

    dialog.vbox.pack_start(hbox2)

    dialog.checkbox = gtk.CheckButton("Use _regular expression")
    dialog.checkbox2 = gtk.CheckButton("Case In_sensitive")
    
    dialog.checkbox.set_active(gconf.client_get_default().\
                    get_int(config_reg + "/regex"))
    dialog.checkbox2.set_active(gconf.client_get_default().\
                    get_int(config_reg + "/nocase"))
            
    dialog.vbox.pack_start(label5)  

    hbox = gtk.HBox()
    hbox.pack_start(label1);  hbox.pack_start(dialog.checkbox)
    hbox.pack_start(label2);  hbox.pack_start(dialog.checkbox2)
    hbox.pack_start(label3);  
    dialog.vbox.pack_start(hbox)
    dialog.vbox.pack_start(label8)  

    if replace:    
        dialog.repl = gtk.Entry();  dialog.repl.set_text(self2.oldrep)
        dialog.repl.set_activates_default(True)
        label10 = gtk.Label("   ");  label11 = gtk.Label("   ") 
        label12 = gtk.Label("   ");  label13 = gtk.Label("   ") 
        hbox3 = gtk.HBox()
        hbox3.pack_start(label10, False)  
        hbox3.pack_start(dialog.repl)  
        hbox3.pack_start(label11, False)  
        dialog.vbox.pack_start(hbox3)  
        dialog.vbox.pack_start(label12)          
        
    dialog.show_all()
    response = dialog.run()   
    self2.oldsearch = entry.get_text()
    self.srctxt = entry.get_text()     
    if replace:    
        self.reptxt = dialog.repl.get_text()

    dialog.destroy()

    if response == gtk.RESPONSE_ACCEPT:
        find_show(self, self2)
Esempio n. 22
0
    def create_edit_gui(self):
        """ Create the gui for the different kinds of watches. """
        vbox_options = self.wTree.get_widget("vbox_edit_options")

        if self.watch.type == 0:
            ###create the web options gui
            tblWeb = gtk.Table(rows=2, columns=2, homogeneous=False)
            tblWeb.set_row_spacings(6)
            tblWeb.set_col_spacings(6)
            tblWeb.show()

            #url
            labelUrl = gtk.Label(_("URL:"))
            labelUrl.set_alignment(xalign=0.0, yalign=0.5)
            labelUrl.show()
            tblWeb.attach(labelUrl, 0, 1, 0, 1)

            self.txtUrl = gtk.Entry()
            self.txtUrl.set_text(self.watch.url_)
            self.txtUrl.show()
            tblWeb.attach(self.txtUrl, 1, 2, 0, 1)

            #error margin
            labelSlider = gtk.Label(_("Error Margin (%):"))
            labelSlider.set_alignment(xalign=0.0, yalign=0.5)
            labelSlider.show()
            tblWeb.attach(labelSlider, 0, 1, 2, 3)

            self.adjustment = gtk.Adjustment(value=2.0,
                                             lower=0,
                                             upper=50,
                                             step_incr=0.1,
                                             page_incr=1.0,
                                             page_size=10)
            self.margin_scale = gtk.HScale(adjustment=self.adjustment)
            self.margin_scale.set_digits(1)
            self.margin_scale.set_value_pos(gtk.POS_RIGHT)
            self.margin_scale.show()
            margin = float(self.watch.error_margin) * 100
            self.margin_scale.set_value(margin)
            self.margin_scale.show()
            tblWeb.attach(self.margin_scale, 0, 2, 3, 4)

            vbox_options.pack_start(tblWeb, False, False, 0)

        elif self.watch.type == 1:
            ###create the mail options gui
            tblMail = gtk.Table(rows=4, columns=2, homogeneous=False)
            tblMail.set_row_spacings(6)
            tblMail.set_col_spacings(6)

            tblMail.show()

            #protocol
            labelProtocol = gtk.Label(_("Protocol:"))
            labelProtocol.set_alignment(xalign=0.0, yalign=0.5)
            labelProtocol.show()
            tblMail.attach(labelProtocol, 0, 1, 0, 1)

            self.labelProtocol_text = gtk.Label()
            self.labelProtocol_text.set_alignment(0.0, 0.0)
            self.labelProtocol_text.show()
            tblMail.attach(self.labelProtocol_text, 1, 2, 0, 1)

            #username
            labelUsername = gtk.Label(_("Username:"******"Password:"******"Host:"))
            labelHost.set_alignment(xalign=0.0, yalign=0.5)
            tblMail.attach(labelHost, 0, 1, 3, 4)

            self.txtHost = gtk.Entry()
            tblMail.attach(self.txtHost, 1, 2, 3, 4)

            #ssl
            labelSsl = gtk.Label(_("Use SSL:"))
            labelSsl.set_alignment(xalign=0.0, yalign=0.5)
            tblMail.attach(labelSsl, 0, 1, 4, 5)

            self.chkSsl = gtk.CheckButton(None, True)
            tblMail.attach(self.chkSsl, 1, 2, 4, 5)

            if self.watch.prot == 0:
                self.labelProtocol_text.set_text(_("Pop3"))
                labelHost.show()
                self.txtHost.set_text(self.watch.host)
                self.txtHost.show()
                labelSsl.show()
                self.chkSsl.show()
                if str(self.watch.ssl) == 'True':
                    self.chkSsl.set_active(True)
                else:
                    self.chkSsl.set_active(False)

            elif self.watch.prot == 1:
                self.labelProtocol_text.set_text(_("Imap"))
                labelHost.show()
                self.txtHost.set_text(self.watch.host)
                self.txtHost.show()
                labelSsl.show()
                self.chkSsl.show()
                if str(self.watch.ssl) == 'True':
                    self.chkSsl.set_active(True)
                else:
                    self.chkSsl.set_active(False)

            else:
                self.labelProtocol_text.set_text(_("Gmail"))

            vbox_options.pack_start(tblMail, False, False, 0)

        elif self.watch.type == 2:
            ###create the file options gui
            tblFile = gtk.Table(rows=2, columns=2, homogeneous=False)
            tblFile.set_row_spacings(6)
            tblFile.set_col_spacings(6)
            tblFile.show()

            #file/folder
            self.labelFile = gtk.Label(_("File/folder:"))
            self.labelFile.set_alignment(xalign=0.0, yalign=0.5)
            self.labelFile.show()
            tblFile.attach(self.labelFile, 0, 1, 0, 1)

            #option file/folder
            vbox_file = gtk.HBox(False, 10)
            vbox_file.show()
            tblFile.attach(vbox_file, 1, 2, 0, 1)

            self.chkFile = gtk.RadioButton(None, _("File"))
            self.chkFile.connect("toggled", self.change_file_type)
            vbox_file.pack_start(self.chkFile, True, True, 0)
            self.chkFile.show()

            self.chkFolder = gtk.RadioButton(self.chkFile, _("Folder"))
            self.chkFolder.connect("toggled", self.change_file_type)
            vbox_file.pack_start(self.chkFolder, True, True, 0)
            self.chkFolder.show()

            #file selection
            self.btnFile = gtk.FileChooserButton(_("Choose a file or folder"))
            self.btnFile.set_filename(self.watch.file)
            self.btnFile.show()
            tblFile.attach(self.btnFile, 0, 2, 1, 2)

            if self.watch.mode == "folder":
                self.chkFolder.set_active(True)
            else:
                self.chkFile.set_active(True)
            self.btnFile.set_filename(self.watch.file)

            vbox_options.pack_start(tblFile, False, False, 0)

        elif self.watch.type == 3:  #add a process
            tblProcess = gtk.Table(rows=2, columns=1, homogeneous=False)
            tblProcess.set_row_spacings(6)
            tblProcess.set_col_spacings(6)
            tblProcess.show()

            labelProcess = gtk.Label(_("Process:"))
            labelProcess.set_alignment(xalign=0.0, yalign=0.5)
            labelProcess.show()
            tblProcess.attach(labelProcess, 0, 1, 0, 1)

            self.txtProcess = gtk.Entry()
            self.txtProcess.set_text(self.watch.process)
            self.txtProcess.show()
            tblProcess.attach(self.txtProcess, 1, 2, 0, 1)

            vbox_options.pack_start(tblProcess, False, False, 0)

        elif self.watch.type == 4:  #add a port
            tblPort = gtk.Table(rows=2, columns=1, homogeneous=False)
            tblPort.set_row_spacings(6)
            tblPort.set_col_spacings(6)
            tblPort.show()

            labelPort = gtk.Label(_("Port:"))
            labelPort.set_alignment(xalign=0.0, yalign=0.5)
            labelPort.show()
            tblPort.attach(labelPort, 0, 1, 0, 1)

            self.txtPort = gtk.Entry()
            self.txtPort.set_text(self.watch.port)
            self.txtPort.show()
            tblPort.attach(self.txtPort, 1, 2, 0, 1)

            vbox_options.pack_start(tblPort, False, False, 0)

        elif self.watch.type == 5:  #add Google Reader
            ###create the GReader options gui
            tblGReader = gtk.Table(rows=2, columns=2, homogeneous=False)
            tblGReader.set_row_spacings(6)
            tblGReader.set_col_spacings(6)
            tblGReader.show()

            #username
            labelUsername = gtk.Label(_("Username:"******"Password:"))
            labelPassword.set_alignment(xalign=0.0, yalign=0.5)
            labelPassword.show()
            tblGReader.attach(labelPassword, 0, 1, 1, 2)

            self.txtPassGr = gtk.Entry()
            self.txtPassGr.set_visibility(False)
            self.txtPassGr.set_text(self.watch.password)
            self.txtPassGr.show()
            tblGReader.attach(self.txtPassGr, 1, 2, 1, 2)

            vbox_options.pack_start(tblGReader, False, False, 0)
Esempio n. 23
0
 def _init(self, data):
     self._widget = gtk.CheckButton("Enabled")
     self._widget.set_active(self._mem_value())
     self._widget.connect("toggled", self.toggled)
Esempio n. 24
0
    def __init__(self, mainWindow, accel_group, syn2d):
        self.xtot = 100
        self.dx = 1

        self.mainWindow = mainWindow
        self.accel_group = accel_group
        self.syn2d = syn2d

        self.vBox = gtk.VBox()
        self.tooltips = gtk.Tooltips()

        # Main Label
        self.label = gtk.Label("<b>" + syn2d.longname + "</b>")
        self.label.set_use_markup(True)
        self.vBox.pack_start(self.label, expand=False)

        #######################
        # Plotter Section
        #######################

        if self.syn2d.canPlotMPL():
            # Seperator
            self.vBox.pack_start(gtk.HSeparator(), expand=False)

            # Plotter selector
            self.plotLabel = gtk.Label("Plot Type")
            self.plotSelect = gtk.combo_box_new_text()
            self.plotSelect.append_text(self.syn2d.PLOT_TYPE_PYLAB)
            self.plotSelect.append_text(self.syn2d.PLOT_TYPE_GMT)
            if self.syn2d.isGMT():
                self.plotSelect.set_active(1)
            else:
                self.plotSelect.set_active(0)
            self.plotBox = gtk.HBox(homogeneous=True, spacing=5)
            self.plotBox.pack_start(self.plotLabel)
            self.plotBox.pack_end(self.plotSelect)
            self.vBox.pack_start(self.plotBox, expand=False)

            self.plotSelect.connect("changed", self.changePlotter)

        # Seperator
        self.vBox.pack_start(gtk.HSeparator(), expand=False)

        #######################
        # Model Section
        #######################

        # Input Model Type
        self.inputModelLabel = gtk.Label("Input Model Type")
        self.inputModelSelect = gtk.combo_box_new_text()
        self.inputModelSelect.append_text("Checkerboard")
        self.inputModelSelect.append_text("Image")
        self.inputModelSelect.set_active(0)
        self.inputModelBox = gtk.HBox(homogeneous=True, spacing=5)
        self.inputModelBox.pack_start(self.inputModelLabel)
        self.inputModelBox.pack_end(self.inputModelSelect)
        self.vBox.pack_start(self.inputModelBox, expand=False)

        # Model Type Settings Box
        self.modelTypeSettingsBox = gtk.VBox()

        # Panel for Checkerboard
        self.checkerboardSizeLabel = gtk.Label("Checkerboard Box Size")
        self.checkerboardSizeEntry = \
            guiUtils.RangeSelectionBox(initial=20, min = 1, max = 100, incr = 10, \
                   digits = 0,buttons = True)
        self.tooltips.set_tip(
            self.checkerboardSizeEntry,
            'the length of each side of each checkerboard box',
            tip_private=None)
        self.checkerboardSizeBox = gtk.HBox(homogeneous=True, spacing=5)
        self.checkerboardSizeBox.pack_start(self.checkerboardSizeLabel)
        self.checkerboardSizeBox.pack_end(self.checkerboardSizeEntry)
        self.checkerboardSizeBox.show_all()
        self.checkerboardSizeEntry.connect('changed', self.modelParamsChanged)
        #self.vBox.pack_start(self.checkerboardSizeBox, expand=False)

        # Image File Selection Box
        self.imageFileLabel = gtk.Label("Image File")
        self.imageFileFileSelect = guiUtils.FileSelectionBox(initial=self.syn2d.getDefaultImage(), \
                    chooseTitle="Select PGM (ASCII, P2) Image File", \
                    width=10, mainWindow=self.mainWindow)
        self.imageFileBox = gtk.HBox(homogeneous=True, spacing=5)
        self.imageFileBox.pack_start(self.imageFileLabel)
        self.tooltips.set_tip(self.imageFileLabel,
                              'read depth dependent density scaling from file',
                              tip_private=None)
        self.imageFileBox.pack_end(self.imageFileFileSelect)
        self.imageFileBox.show_all()
        self.imageFileFileSelect.connect('changed', self.modelParamsChanged)
        #self.vBox.pack_start(self.imageFileBox, expand=False)

        # set it up so that it switches what's shown based on image/checkerboard being selected
        self.inputModelSelect.connect("changed", self.populateModelSettings)
        self.vBox.pack_start(self.modelTypeSettingsBox, expand=False)

        # model buttons
        self.modelButtonBox = gtk.HBox(homogeneous=True, spacing=5)
        self.makeModelButton = gtk.Button("Make Model")
        self.plotModelButton = gtk.Button("Plot Model")
        self.makeModelButton.connect("clicked", self.makeModel)
        self.plotModelButton.connect("clicked", self.plotModel)
        self.modelButtonBox.pack_start(self.makeModelButton)
        self.modelButtonBox.pack_start(self.plotModelButton)
        self.plotModelButton.set_sensitive(False)
        self.vBox.pack_start(self.modelButtonBox, expand=False)

        # Seperator
        self.vBox.pack_start(gtk.HSeparator(), expand=False)

        #######################
        # Data Section
        #######################

        self.dataVBox = gtk.VBox()

        # Station Mode
        self.stationModeLabel = gtk.Label("Station Mode")
        self.stationModeSelect = gtk.combo_box_new_text()
        self.stationModeSelect.append_text("Evenly Distributed")
        self.stationModeSelect.append_text("Clustered in the Center")
        self.stationModeSelect.append_text(
            "Roughly Circular Region Around\nEvenly Distributed Events")
        self.stationModeSelect.append_text("Roughly Circular Region")
        self.stationModeSelect.set_active(0)
        self.stationModeBox = gtk.HBox(homogeneous=True, spacing=5)
        self.stationModeBox.pack_start(self.stationModeLabel)
        self.stationModeBox.pack_end(self.stationModeSelect)
        self.stationModeSelect.connect("changed", self.dataParamsChanged)
        self.dataVBox.pack_start(self.stationModeBox, expand=False)

        # Synthetic Generated Data Points (ndata) box
        self.ndataLabel = gtk.Label("Synth Gen Data Pnts")
        self.ndataEntry = \
            guiUtils.RangeSelectionBox(initial=4000, min = 1, max = 20000, incr = 1000, \
                   digits = 0,buttons = True)
        self.tooltips.set_tip(
            self.ndataEntry,
            'the total number of synthetically generated data points, i.e. station-receiver pairs',
            tip_private=None)
        self.ndataBox = gtk.HBox(homogeneous=True, spacing=5)
        self.ndataBox.pack_start(self.ndataLabel)
        self.ndataBox.pack_end(self.ndataEntry)
        self.ndataEntry.connect("changed", self.dataParamsChanged)
        self.dataVBox.pack_start(self.ndataBox, expand=False)

        # Recordings Per Event (ipick) box
        self.ipickLabel = gtk.Label("Num Recordings per Event")
        self.ipickEntry = \
            guiUtils.RangeSelectionBox(initial=20, min = 1, max = 50, incr = 10, \
                   digits = 0, buttons = True)
        self.tooltips.set_tip(
            self.ipickEntry,
            'the number of recordings (at different stations) for each event',
            tip_private=None)
        self.ipickBox = gtk.HBox(homogeneous=True, spacing=5)
        self.ipickBox.pack_start(self.ipickLabel)
        self.ipickBox.pack_end(self.ipickEntry)
        self.ipickEntry.connect("changed", self.dataParamsChanged)
        self.dataVBox.pack_start(self.ipickBox, expand=False)

        # Noise box (sigma) box
        self.noiseLabel = gtk.Label("Noise (sigma)")
        self.noiseEntry = \
            guiUtils.LogRangeSelectionBox(initial=0.25, min = 0, max = 10, incr = 1, \
                   digits = 4, buttons = True)
        self.tooltips.set_tip(self.noiseEntry,
                              'sigma value for specifying noise',
                              tip_private=None)
        self.noiseBox = gtk.HBox(homogeneous=True, spacing=5)
        self.noiseBox.pack_start(self.noiseLabel)
        self.noiseBox.pack_end(self.noiseEntry)
        self.noiseEntry.connect("changed", self.dataParamsChanged)
        self.dataVBox.pack_start(self.noiseBox, expand=False)

        # Data Buttons
        self.dataButtonBox = gtk.HBox(homogeneous=True, spacing=5)
        self.makeDataButton = gtk.Button("Generate Data")
        self.editDataButton = gtk.Button("Load/Edit Data")
        self.plotDataButton = gtk.Button("Plot Data")
        self.makeDataButton.connect("clicked", self.makeData)
        self.editDataButton.connect("clicked", self.editData)
        self.plotDataButton.connect("clicked", self.plotData)
        self.dataLeftButtonBox = gtk.VBox()
        self.dataLeftButtonBox.pack_start(self.makeDataButton)
        if self.syn2d.canPlotMPL() and edit:
            self.dataLeftButtonBox.pack_end(self.editDataButton)
        self.dataButtonBox.pack_start(self.dataLeftButtonBox)

        self.plotDataBox = gtk.VBox()
        self.plotSourcesCheck = gtk.CheckButton("Sources")
        self.plotSourcesCheck.set_active(True)
        self.plotSourcesCheck.connect("clicked", self.setDataChanged)
        self.plotReceiversCheck = gtk.CheckButton("Receivers")
        self.plotReceiversCheck.set_active(True)
        self.plotReceiversCheck.connect("clicked", self.setDataChanged)
        self.plotPathsCheck = gtk.CheckButton("Paths")
        self.plotPathsCheck.set_active(False)
        self.plotPathsCheck.connect("clicked", self.setDataChanged)
        self.plotModelWithDataCheck = gtk.CheckButton("Model")
        self.plotModelWithDataCheck.set_active(False)
        self.plotModelWithDataCheck.connect("clicked", self.setDataChanged)
        self.plotDataBox.pack_start(self.plotDataButton)
        self.plotDataMidBox = gtk.HBox()
        self.plotDataMidBox.pack_start(self.plotSourcesCheck)
        self.plotDataMidBox.pack_start(self.plotReceiversCheck)
        self.plotDataMidBox2 = gtk.HBox()
        self.plotDataMidBox2.pack_start(self.plotPathsCheck)
        self.plotDataMidBox2.pack_start(self.plotModelWithDataCheck)
        self.plotDataBox.pack_start(self.plotDataMidBox)
        self.plotDataBox.pack_start(self.plotDataMidBox2)
        self.plotDataBox.set_sensitive(False)

        self.dataButtonBox.pack_start(self.plotDataBox)

        self.dataVBox.pack_start(self.dataButtonBox, expand=False)

        # Make it all disabled until ready
        self.dataVBox.set_sensitive(False)

        # Data Section Box
        self.vBox.pack_start(self.dataVBox, expand=False)

        # Seperator
        self.vBox.pack_start(gtk.HSeparator(), expand=False)

        #######################
        # Inversion Section
        #######################

        self.inversionVBox = gtk.VBox()

        # Damping Value
        self.dampLabel = gtk.Label("Damping Value")
        self.dampEntry = \
            guiUtils.LogRangeSelectionBox(initial=1, min = 0, max = 100, incr = 0.5, \
                   digits = 3,buttons = True)
        self.tooltips.set_tip(self.dampEntry,
                              'norm damping setting for the inversion step',
                              tip_private=None)
        self.dampBox = gtk.HBox(homogeneous=True, spacing=5)
        self.dampBox.pack_start(self.dampLabel)
        self.dampBox.pack_end(self.dampEntry)
        self.dampEntry.connect("changed", self.inversionParamsChanged)
        self.inversionVBox.pack_start(self.dampBox, expand=False)

        # Invert Buttons
        self.inversionButtonBox = gtk.HBox(homogeneous=True, spacing=5)
        self.invertButton = gtk.Button("Invert Data")
        self.invertPlotBox = gtk.VBox()
        self.plotInversionButton = gtk.Button("Plot Inversion")
        self.diffBox = gtk.HBox(homogeneous=False)
        self.absDiffCheck = gtk.CheckButton("Absolute")
        self.plotDifferenceButton = gtk.Button("Plot Diff")
        self.invertButton.connect("clicked", self.invertData)
        self.plotDifferenceButton.connect("clicked", self.plotDifference)
        self.plotInversionButton.connect("clicked", self.plotInversion)
        self.inversionButtonBox.pack_start(self.invertButton)
        self.invertPlotBox.pack_start(self.plotInversionButton)
        self.diffBox.pack_start(self.absDiffCheck)
        self.diffBox.pack_start(self.plotDifferenceButton,
                                expand=True,
                                fill=True)
        self.invertPlotBox.pack_start(self.diffBox)
        self.inversionButtonBox.pack_start(self.invertPlotBox)
        self.plotInversionButton.set_sensitive(False)
        self.diffBox.set_sensitive(False)
        self.inversionVBox.pack_start(self.inversionButtonBox, expand=False)

        # Invert Includes
        self.inversionIncludeBox = gtk.HBox(homogeneous=False, spacing=5)
        self.inversionIncludeLabel = gtk.Label("Show:")
        self.invSourcesCheck = gtk.CheckButton("Sources")
        self.invSourcesCheck.connect("clicked", self.setInversionChanged)
        self.invSourcesCheck.set_active(False)
        self.invRecieversCheck = gtk.CheckButton("Receivers")
        self.invRecieversCheck.connect("clicked", self.setInversionChanged)
        self.invRecieversCheck.set_active(False)
        self.invPathsCheck = gtk.CheckButton("Paths")
        self.invPathsCheck.connect("clicked", self.setInversionChanged)
        self.invPathsCheck.set_active(False)
        self.inversionIncludeBox.pack_start(self.inversionIncludeLabel)
        self.inversionIncludeBox.pack_start(self.invSourcesCheck)
        self.inversionIncludeBox.pack_start(self.invRecieversCheck)
        self.inversionIncludeBox.pack_start(self.invPathsCheck)

        # Make it all disabled until ready
        self.inversionVBox.set_sensitive(False)
        self.inversionIncludeBox.set_sensitive(False)

        # Inversion Section Box
        self.vBox.pack_start(self.inversionVBox, expand=False)
        self.vBox.pack_start(self.inversionIncludeBox, expand=False)

        # setup the right model panel
        self.populateModelSettings()

        # Make Everything Visible
        self.vBox.set_size_request(375, -1)
        self.vBox.show_all()

        # boolean values to track if the data has been remade for replotting verses restoring old plot
        self.modelChanged = False
        self.dataChanged = False
        self.inversionChanged = False
        self.lastInvDifference = False

        # PS files for each plot
        self.modelPSFile = ""
        self.dataPSFile = ""
        self.inversionPSFile = ""
        self.differencePSFile = ""
Esempio n. 25
0
    def show(self):  #the first report error window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_border_width(15)
        self.window.set_title("Report Error")

        self.box = gtk.VBox(False, 5)  #contains all the widgets
        self.window.add(self.box)

        hbox = gtk.HBox()
        self.box.pack_start(hbox)
        label = gtk.Label(
            "Choose what information to include in the error report."
            " The more information you include, the easier it will be"
            " to pinpoint the cause of the error.")
        label.set_line_wrap(True)
        label.modify_font(pango.FontDescription("italic "))
        label.set_alignment(0, 0)
        hbox.pack_start(label)
        label.show()
        hbox.show()

        # User chooses which logs to include
        label = gtk.Frame('Include:')
        self.box.pack_start(label, False, False, 0)
        self.box2 = gtk.VBox(False, 2)
        label.add(self.box2)
        self.pythonLogButton = gtk.CheckButton("Python Log")
        self.pythonLogButton.set_active(True)
        self.pythonplusLogButton = gtk.CheckButton("Python Log with Outputs")
        self.pythonplusLogButton.set_active(True)
        self.instalLogButton = gtk.CheckButton("Installation Log")
        self.instalLogButton.set_active(True)
        self.tracebackButton = gtk.CheckButton("Traceback file")
        self.tracebackButton.set_active(True)
        self.box2.pack_start(self.pythonLogButton)
        self.box2.pack_start(self.pythonplusLogButton)
        self.box2.pack_start(self.instalLogButton)
        self.box2.pack_start(self.tracebackButton)
        self.pythonLogButton.show()
        self.pythonplusLogButton.show()
        self.instalLogButton.show()
        self.tracebackButton.hide()
        self.box2.show()
        label.show()

        reporterror.parseFiles(
            reporterror.getPythonLog)  # finds all the file calls in pythonlog

        #User input files to include
        self.box3 = gtk.HBox(False, 0)
        label = gtk.Frame('Input Files to Include:')
        self.add_file = gtk.Button(stock=gtk.STOCK_ADD)
        self.add_file.connect("clicked", self.add_button)
        #tooltips.set_tooltip_text(self.add_file, "Allow user to manually add input files.")
        self.box3.pack_start(label, True, True, 0)
        self.box3.pack_start(self.add_file, False, False, 0)
        self.add_file.show()
        self.box.pack_start(self.box3, True, True, 0)
        self.box31 = gtk.VBox(False, 2)
        label.add(self.box31)
        self.infilenames = reporterror.getInfiles()
        self.infilebuttons = []
        for file in self.infilenames:
            self.infilebuttons.append(gtk.CheckButton(file))
        for button in self.infilebuttons:
            self.box31.pack_start(button)
            button.set_active(True)
            button.show()
        self.box31.show()
        label.show()  #show files box
        self.box3.show()

        #User output files to include
        label = gtk.Frame('Output Files to Include:')
        self.box.pack_start(label, False, False, 0)
        self.box4 = gtk.VBox(False, 2)
        label.add(self.box4)
        self.outfilenames = reporterror.getOutfiles()
        self.outfilebuttons = []
        for file in self.outfilenames:
            self.outfilebuttons.append(gtk.CheckButton(file))
        for button in self.outfilebuttons:
            self.box4.pack_start(button)
            button.set_active(True)
            button.show()
        self.box4.show()
        label.show()  #show

        #Option to include files that have been deleted from the system
        label = gtk.Frame('')
        self.box.pack_start(label)
        self.delfiles = reporterror.getDelfiles()
        files = "( "
        i = 1
        for file in self.delfiles:  #Formatting the files list
            if (i % 2 == 0):
                file = file + '\n'
            files = files + '\'' + file + '\' '
            i += 1
        files = files + ')'
        self.deletedfilesbutton = gtk.CheckButton(
            "Include names of input/output files that are no longer in the system:\n"
            + files)
        self.deletedfilesbutton.set_active(True)
        label.add(self.deletedfilesbutton)
        if (self.delfiles != []):
            self.deletedfilesbutton.show()
            label.show()

#Comments Sections
        label = gtk.Frame('Additional Comments:')
        self.box.pack_start(label)
        self.box5 = gtk.VBox(False, 2)
        hbox = gtk.HBox(False, 100)
        label.add(self.box5)
        self.box5.pack_start(hbox)
        text = gtk.Label("What did you do? What went wrong?")
        text.modify_font(pango.FontDescription("italic "))
        text.set_alignment(0, 0)
        hbox.pack_start(text, False, False, 0)
        text.show()
        hbox.show()
        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.textview = fixedwidthtext.FixedWidthTextView()
        scroll.add(self.textview)
        scroll.show()
        self.textview.show()
        self.box5.pack_start(scroll)
        self.box5.show()
        label.show()

        self.window.set_default_size(
            60 * gtkutils.widgetCharSize(self.textview), -1)

        # OK and CANCEL Buttons
        self.end = gtk.HBox(False, 100)
        self.button1 = gtk.Button(stock=gtk.STOCK_OK)
        self.button1.connect("clicked", self.okbutton1)
        self.end.pack_start(self.button1, True, True, 0)
        self.button1.show()
        self.button2 = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.button2.connect("clicked", self.cancelbutton, self.window)
        self.end.pack_start(self.button2, True, True, 0)
        self.button2.show()
        self.box.pack_start(self.end, True, True, 0)
        self.end.show()

        self.box.show()
        self.window.show()
Esempio n. 26
0
    def __init__(self):

        self.columns = ["ID","Name","Lastname","Gender","DoB","Phone","Address"]

        icon = os.path.expanduser("~") + \
            '/gnuhealth_plugins/frl/icons/federation.svg'

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_icon_from_file(icon)

        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)

        # Border and title
        self.window.set_border_width(10)
        self.window.set_title("GNU Health Federation Resource Locator")

        # Entry for the resource (eg, people)
        self.resource = gtk.Entry(max=20)
        self.resource.set_text("people")

        # Entry to find Federation ID or other info when using fuzzy srch
        self.query = gtk.Entry(max=100)

        # Search Button
        self.search_button = gtk.Button(label=None, stock=gtk.STOCK_FIND)

        # Fuzzy search
        self.fuzzy_search = gtk.CheckButton(label="Fuzzy")

        # Call method search_resource upon receiving the clicked signal
        self.search_button.connect("clicked", self.search_resource,
            self.resource, self.query, self.fuzzy_search)

        self.hbox = gtk.HBox (True, 10)
        self.hbox.pack_start (self.resource)
        self.hbox.pack_start (self.query)
        self.hbox.pack_start (self.search_button)
        self.hbox.pack_start (self.fuzzy_search)
        self.resource.show()
        self.query.show()
        self.search_button.show()
        self.fuzzy_search.show()

        self.search_frame = gtk.Frame()
        self.search_frame.add (self.hbox)

        self.main_table = gtk.Table(rows=2, columns=2, homogeneous=False)

        # Create the main tree view for the results
        self.results = gtk.ListStore(str, str, str, str, str, str, str)
        self.treeview = gtk.TreeView(self.results)

        # Let pick at most one row
        self.treeselection = self.treeview.get_selection ()
        self.treeselection.set_mode (gtk.SELECTION_SINGLE)
        # Process once the row is activated (double-click or enter)
        self.treeview.connect('row-activated', self.get_values)

        # Add and render the columns
        for n in range(len(self.columns)):
            self.cell = gtk.CellRendererText()
            self.col = gtk.TreeViewColumn(self.columns[n], self.cell, text=n)
            self.treeview.append_column(self.col)

        # attach the query box on the table
        self.main_table.attach(self.search_frame,0,1,0,1)

        # attach the query box on the table
        self.main_table.attach(self.treeview,0,1,1,2)
        self.window.add (self.main_table)

        # Display the objects
        self.hbox.show()
        self.search_frame.show()
        self.treeview.show()
        self.main_table.show()
        self.window.show()
Esempio n. 27
0
    def dialog_tablehandle(self, title, is_insert):
        """Opens the Table Handle Dialog"""
        dialog = gtk.Dialog(
            title=title,
            parent=self.dad.window,
            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK,
                     gtk.RESPONSE_ACCEPT))
        dialog.set_default_size(300, -1)
        dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        label_rows = gtk.Label(_("Rows"))
        adj_rows = gtk.Adjustment(value=self.dad.table_rows,
                                  lower=1,
                                  upper=10000,
                                  step_incr=1)
        spinbutton_rows = gtk.SpinButton(adj_rows)
        spinbutton_rows.set_value(self.dad.table_rows)
        label_columns = gtk.Label(_("Columns"))
        adj_columns = gtk.Adjustment(value=self.dad.table_columns,
                                     lower=1,
                                     upper=10000,
                                     step_incr=1)
        spinbutton_columns = gtk.SpinButton(adj_columns)
        spinbutton_columns.set_value(self.dad.table_columns)

        hbox_rows_cols = gtk.HBox()
        hbox_rows_cols.pack_start(label_rows, expand=False)
        hbox_rows_cols.pack_start(spinbutton_rows, expand=False)
        hbox_rows_cols.pack_start(label_columns, expand=False)
        hbox_rows_cols.pack_start(spinbutton_columns, expand=False)
        hbox_rows_cols.set_spacing(5)
        size_align = gtk.Alignment()
        size_align.set_padding(6, 6, 6, 6)
        size_align.add(hbox_rows_cols)

        size_frame = gtk.Frame(label="<b>" + _("Table Size") + "</b>")
        size_frame.get_label_widget().set_use_markup(True)
        size_frame.set_shadow_type(gtk.SHADOW_NONE)
        size_frame.add(size_align)

        label_col_min = gtk.Label(_("Min Width"))
        adj_col_min = gtk.Adjustment(value=self.dad.table_col_min,
                                     lower=1,
                                     upper=10000,
                                     step_incr=1)
        spinbutton_col_min = gtk.SpinButton(adj_col_min)
        spinbutton_col_min.set_value(self.dad.table_col_min)
        label_col_max = gtk.Label(_("Max Width"))
        adj_col_max = gtk.Adjustment(value=self.dad.table_col_max,
                                     lower=1,
                                     upper=10000,
                                     step_incr=1)
        spinbutton_col_max = gtk.SpinButton(adj_col_max)
        spinbutton_col_max.set_value(self.dad.table_col_max)

        hbox_col_min_max = gtk.HBox()
        hbox_col_min_max.pack_start(label_col_min, expand=False)
        hbox_col_min_max.pack_start(spinbutton_col_min, expand=False)
        hbox_col_min_max.pack_start(label_col_max, expand=False)
        hbox_col_min_max.pack_start(spinbutton_col_max, expand=False)
        hbox_col_min_max.set_spacing(5)
        col_min_max_align = gtk.Alignment()
        col_min_max_align.set_padding(6, 6, 6, 6)
        col_min_max_align.add(hbox_col_min_max)

        col_min_max_frame = gtk.Frame(label="<b>" + _("Column Properties") +
                                      "</b>")
        col_min_max_frame.get_label_widget().set_use_markup(True)
        col_min_max_frame.set_shadow_type(gtk.SHADOW_NONE)
        col_min_max_frame.add(col_min_max_align)

        checkbutton_table_ins_from_file = gtk.CheckButton(
            label=_("Import from CSV File"))

        content_area = dialog.get_content_area()
        content_area.set_spacing(5)
        if is_insert: content_area.pack_start(size_frame)
        content_area.pack_start(col_min_max_frame)
        if is_insert: content_area.pack_start(checkbutton_table_ins_from_file)
        content_area.show_all()

        def on_key_press_tablehandle(widget, event):
            keyname = gtk.gdk.keyval_name(event.keyval)
            if keyname == cons.STR_KEY_RETURN:
                spinbutton_rows.update()
                spinbutton_columns.update()
                spinbutton_col_min.update()
                spinbutton_col_max.update()
                try:
                    dialog.get_widget_for_response(
                        gtk.RESPONSE_ACCEPT).clicked()
                except:
                    print cons.STR_PYGTK_222_REQUIRED
                return True
            return False

        def on_checkbutton_table_ins_from_file_toggled(checkbutton):
            size_frame.set_sensitive(not checkbutton.get_active())
            col_min_max_frame.set_sensitive(not checkbutton.get_active())

        dialog.connect('key_press_event', on_key_press_tablehandle)
        checkbutton_table_ins_from_file.connect(
            'toggled', on_checkbutton_table_ins_from_file_toggled)
        response = dialog.run()
        dialog.hide()
        if response == gtk.RESPONSE_ACCEPT:
            self.dad.table_rows = int(spinbutton_rows.get_value())
            self.dad.table_columns = int(spinbutton_columns.get_value())
            self.dad.table_col_min = int(spinbutton_col_min.get_value())
            self.dad.table_col_max = int(spinbutton_col_max.get_value())
            ret_csv = checkbutton_table_ins_from_file.get_active()
            return [True, ret_csv]
        return [False, None]
Esempio n. 28
0
    def build_gui(self):
        self.win = gtk.Window()
        self.win.set_title("Elicit")
        self.win.set_icon_name('rephorm-elicit')
        self.win.connect('destroy', self.quit, None)

        vbox = gtk.VBox(False, 2)
        self.win.add(vbox)

        menubar = self.build_menu()
        vbox.pack_start(menubar, False)

        # notebook with magnifier, etc
        hbox = gtk.HBox(False, 0)
        vbox.pack_start(hbox, True, True)
        notebook = gtk.Notebook()
        self.notebook = notebook
        hbox.pack_start(notebook, True, True, padding=HPAD)

        # magnifier tab
        mag_vbox = gtk.VBox(False, 2)
        mag_tab_icon = gtk.Image()
        mag_tab_icon.set_from_file(
            os.path.join(self.icon_path, "magnify-16.png"))
        notebook.append_page(mag_vbox, mag_tab_icon)

        # the magnifier
        hbox = gtk.HBox(False, 0)
        mag_vbox.pack_start(hbox, True, True)

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(frame, True, True, padding=HPAD)

        self.mag = Magnifier()
        frame.add(self.mag)
        self.mag.connect('zoom-changed', self.mag_zoom_changed)
        self.mag.connect('grid-toggled', self.mag_grid_toggled)
        self.mag.connect('measure-changed', self.mag_measure_changed)
        self.mag.connect('location-changed', self.mag_location_changed)

        # magnifier information (coordinates)
        hbox = gtk.HBox(False, 0)
        mag_vbox.pack_start(hbox, False)

        self.mag_label = gtk.Label()
        hbox.pack_start(self.mag_label, False, padding=HPAD)

        self.measure_label = gtk.Label()
        hbox.pack_end(self.measure_label, False)

        # magnifier tools
        hbox = gtk.HBox(False, 0)
        mag_vbox.pack_start(hbox, False)

        button = gtk.Button()
        button.set_relief(gtk.RELIEF_NONE)
        img = gtk.Image()
        img.set_from_file(os.path.join(self.icon_path, "magnify-button.png"))
        button.set_image(img)
        button.set_tooltip_text("Start Magnifying\n(Left Click to stop)")
        button.connect('clicked', self.magnify_clicked)
        hbox.pack_end(button, False, padding=HPAD)

        check = gtk.CheckButton("Show Grid")
        check.set_active(self.mag.show_grid)
        check.connect('toggled', self.grid_check_toggled)
        hbox.pack_start(check, padding=HPAD)
        self.grid_check = check

        spin = gtk.SpinButton()
        spin.set_range(1, 50)
        spin.set_increments(1, 10)
        spin.set_value(self.mag.zoom)
        spin.connect('value-changed', self.zoom_spin_value_changed)
        hbox.pack_end(spin, False, padding=HPAD)
        self.zoom_spin = spin

        zoom_label = gtk.Label("Zoom:")
        hbox.pack_end(zoom_label, False)

        # color wheel
        wheel_frame = gtk.Frame()
        wheel_tab_icon = gtk.Image()
        wheel_tab_icon.set_from_file(
            os.path.join(self.icon_path, "color-wheel-16.png"))
        notebook.append_page(wheel_frame, wheel_tab_icon)

        if hasattr(gtk, 'HSV'):
            wheel = gtk.HSV()
            self.wheel = wheel
            wheel_frame.add(wheel)

            wheel_frame.connect('size-allocate', self.wheel_size_allocate)
            wheel_frame.connect('size-request', self.wheel_size_request)
            wheel.connect('changed', self.wheel_changed)
        else:
            self.wheel = None
            label = gtk.Label(
                "The color wheel requires gtk ver. 2.28 or higher.")
            wheel_frame.add(label)

        # swatch and eyedropper button
        hbox = gtk.HBox(False, 0)
        vbox.pack_start(hbox, False)

        button = gtk.Button()
        button.set_relief(gtk.RELIEF_NONE)
        img = gtk.Image()
        img.set_from_file(os.path.join(self.icon_path, "dropper-button.png"))
        button.set_image(img)
        button.set_tooltip_text("Start Selecting Color\n(Left Click to stop)")
        button.connect('clicked', self.select_color_clicked)
        hbox.pack_end(button, False, padding=HPAD)

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(frame, True, True, padding=HPAD)

        self.colorpicker = ColorPicker()
        frame.add(self.colorpicker)
        self.colorpicker.connect('save-color', self.picker_save_color)
        self.colorpicker.set_magnifier(self.mag)

        # color values (sliders and spinboxes)
        hbox = gtk.HBox(False, 5)
        vbox.pack_start(hbox, False)

        self.colorspin = {}

        table = gtk.Table(6, 4)
        hbox.pack_start(table, True, True, padding=HPAD)

        row = 0
        for type in ("r", "g", "b"):
            label = gtk.Label(type.upper())
            table.attach(label, 0, 1, row, row + 1, 0, 0, 2, 2)
            cslider = CSlider(self.color, type)
            table.attach(cslider, 1, 2, row, row + 1, gtk.FILL | gtk.EXPAND,
                         gtk.EXPAND, 2, 2)
            spin = gtk.SpinButton()
            spin.set_range(0, 255)
            spin.set_increments(1, 10)
            spin.connect('value-changed', self.color_spin_rgb_changed)
            table.attach(spin, 2, 3, row, row + 1, 0, gtk.EXPAND, 2, 2)
            self.colorspin[type] = spin
            row += 1

        row = 0
        for type in ("h", "s", "v"):
            label = gtk.Label(type.upper())
            table.attach(label, 3, 4, row, row + 1, 0, 0, 2, 2)
            cslider = CSlider(self.color, type)
            table.attach(cslider, 4, 5, row, row + 1, gtk.FILL | gtk.EXPAND,
                         gtk.EXPAND, 2, 2)
            spin = gtk.SpinButton()
            if type == 'h':
                spin.set_range(0, 360)
                spin.set_increments(1, 10)
            else:
                spin.set_digits(2)
                spin.set_range(0, 1.0)
                spin.set_increments(.01, .1)
            spin.connect('value-changed', self.color_spin_hsv_changed)
            table.attach(spin, 5, 6, row, row + 1, 0, gtk.EXPAND, 2, 2)
            self.colorspin[type] = spin
            row += 1

        self.hex_label = gtk.Label("Hex")
        table.attach(self.hex_label, 0, 1, 3, 4, gtk.FILL, gtk.EXPAND, 2, 2)

        self.hex_entry = gtk.Entry()
        table.attach(self.hex_entry, 1, 6, 3, 4, gtk.FILL, gtk.EXPAND, 2, 2)
        self.hex_entry.connect('changed', self.hex_entry_changed)

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

        # palette tools
        hbox = gtk.HBox(False, 5)
        vbox.pack_start(hbox, False)

        hbox.pack_start(gtk.Label("Palette:"), False, padding=HPAD)

        self.palette_combo = PaletteCombo()
        hbox.pack_start(self.palette_combo)
        self.palette_combo.connect('selected', self.palette_combo_selected)

        button = gtk.Button()
        button.set_image(
            gtk.image_new_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON))
        button.set_tooltip_text("Add Palette")
        button.set_relief(gtk.RELIEF_NONE)
        button.connect('clicked', self.add_palette)
        hbox.pack_start(button, False)

        button = gtk.Button()
        button.set_image(
            gtk.image_new_from_stock(gtk.STOCK_DELETE, gtk.ICON_SIZE_BUTTON))
        button.set_tooltip_text("Delete Palette")
        button.set_relief(gtk.RELIEF_NONE)
        button.connect('clicked', self.delete_palette)
        hbox.pack_start(button, False, padding=HPAD)

        # palette view
        hbox = gtk.HBox(False, 5)
        vbox.pack_start(hbox, False)

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(frame, True, padding=HPAD)

        self.palette_view = PaletteView()
        self.palette_view.connect('select-color',
                                  self.palette_view_select_color)
        self.palette_view.connect('delete-color',
                                  self.palette_view_delete_color)
        frame.add(self.palette_view)

        # color name entry
        hbox = gtk.HBox(False, 5)
        vbox.pack_start(hbox, False, padding=VPAD)

        hbox.pack_start(gtk.Label("Color Name:"), False, padding=HPAD)

        self.color_name_entry = gtk.Entry()
        self.color_name_entry.set_sensitive(False)
        self.color_name_entry.connect('changed', self.color_name_entry_changed)
        hbox.pack_start(self.color_name_entry, True, True, padding=HPAD)
Esempio n. 29
0
 def do_polygon(self, fWizard, tmpDir):
     self.tmpDir = tmpDir
     self.fWizard = fWizard
     self.W = gtk.Dialog('Polygon',
                         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)
     cLabel = gtk.Label('Cut Type')
     cLabel.set_alignment(0.95, 0.5)
     cLabel.set_width_chars(10)
     t.attach(cLabel, 0, 1, 0, 1)
     self.outside = gtk.RadioButton(None, 'Outside')
     t.attach(self.outside, 1, 2, 0, 1)
     inside = gtk.RadioButton(self.outside, 'Inside')
     t.attach(inside, 2, 3, 0, 1)
     oLabel = gtk.Label('Offset')
     oLabel.set_alignment(0.95, 0.5)
     oLabel.set_width_chars(10)
     t.attach(oLabel, 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)
     bLeft = gtk.RadioButton(self.centre, 'Bottom Left')
     t.attach(bLeft, 0, 1, 5, 6)
     sLabel = gtk.Label('Sides')
     sLabel.set_alignment(0.95, 0.5)
     sLabel.set_width_chars(10)
     t.attach(sLabel, 0, 1, 6, 7)
     self.sEntry = gtk.Entry()
     self.sEntry.set_width_chars(10)
     t.attach(self.sEntry, 1, 2, 6, 7)
     self.mCombo = gtk.combo_box_new_text()
     self.mCombo.append_text('Circumscribed Diameter')
     self.mCombo.append_text('Inscribed Diameter')
     self.mCombo.append_text('Side Length')
     self.mCombo.set_active(0)
     self.mCombo.connect('changed', self.mode_changed)
     t.attach(self.mCombo, 0, 2, 7, 8)
     self.dLabel = gtk.Label('Diameter')
     self.dLabel.set_alignment(0.95, 0.5)
     self.dLabel.set_width_chars(10)
     t.attach(self.dLabel, 0, 1, 8, 9)
     self.dEntry = gtk.Entry()
     self.dEntry.set_width_chars(10)
     t.attach(self.dEntry, 1, 2, 8, 9)
     aLabel = gtk.Label('Angle')
     aLabel.set_alignment(0.95, 0.5)
     aLabel.set_width_chars(10)
     t.attach(aLabel, 0, 1, 9, 10)
     self.aEntry = gtk.Entry()
     self.aEntry.set_width_chars(10)
     self.aEntry.set_text('0')
     t.attach(self.aEntry, 1, 2, 9, 10)
     preview = gtk.Button('Preview')
     preview.connect('pressed', self.send_preview)
     t.attach(preview, 0, 1, 11, 12)
     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, 11, 12)
     end = gtk.Button('Return')
     end.connect('pressed', self.end_this_shape)
     t.attach(end, 4, 5, 11, 12)
     pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
         filename='./wizards/images/polygon.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('lead-in'):
                 self.liEntry.set_text(line.strip().split('=')[1])
             elif line.startswith('lead-out'):
                 self.loEntry.set_text(line.strip().split('=')[1])
     response = self.W.run()
Esempio n. 30
0
    def __init__(self):
        TweakModule.__init__(self)

        self.to_add = []
        self.to_rm = []
        self.button_list = []
        self.current_button = 0

        hbox = gtk.HBox(False, 12)
        self.add_start(hbox, True, True, 0)

        sw = gtk.ScrolledWindow()
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        hbox.pack_start(sw)

        vbox = gtk.VBox(False, 6)
        hbox.pack_start(vbox, False, False, 0)

        # create tree view
        self.treeview = PackageView()
        self.treeview.set_rules_hint(True)
        self.treeview.connect('checked', self.on_item_checked)
        self.treeview.connect('cleaned', self.on_item_cleaned)
        sw.add(self.treeview)

        # create the button
        self.pkg_button = self.create_button(
            _('Clean Packages'),
            gtk.image_new_from_pixbuf(icon.get_from_name('deb')),
            self.treeview.update_package_model)
        vbox.pack_start(self.pkg_button, False, False, 0)

        self.cache_button = self.create_button(
            _('Clean Cache'),
            gtk.image_new_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_BUTTON),
            self.treeview.update_cache_model)
        vbox.pack_start(self.cache_button, False, False, 0)

        self.config_button = self.create_button(
            _('Clean Config'),
            gtk.image_new_from_stock(gtk.STOCK_PREFERENCES,
                                     gtk.ICON_SIZE_BUTTON),
            self.treeview.update_config_model)
        vbox.pack_start(self.config_button, False, False, 0)

        self.kernel_button = self.create_button(
            _('Clean Kernels'),
            gtk.image_new_from_pixbuf(icon.get_from_name('start-here')),
            self.treeview.update_kernel_model)
        vbox.pack_start(self.kernel_button, False, False, 0)

        self.ppa_button = self.create_button(
            _('Purge PPAs'),
            gtk.image_new_from_pixbuf(icon.get_from_name('start-here')),
            self.treeview.update_ppa_model)
        vbox.pack_start(self.ppa_button, False, False, 0)

        # checkbutton
        self.select_button = gtk.CheckButton(_('Select All'))
        self.select_button.set_sensitive(False)
        self.__handler_id = self.select_button.connect('toggled',
                                                       self.on_select_all)
        self.add_start(self.select_button, False, False, 0)

        # button
        hbuttonbox = gtk.HButtonBox()
        hbuttonbox.set_spacing(12)
        hbuttonbox.set_layout(gtk.BUTTONBOX_END)
        self.add_end(hbuttonbox, False, False, 0)

        self.clean_button = gtk.Button(stock=gtk.STOCK_CLEAR)
        set_label_for_stock_button(self.clean_button, _('_Cleanup'))
        self.clean_button.connect('clicked', self.on_clean_button_clicked)
        self.clean_button.set_sensitive(False)
        hbuttonbox.pack_end(self.clean_button, False, False, 0)

        un_lock = PolkitButton()
        un_lock.connect('changed', self.on_polkit_action)
        hbuttonbox.pack_end(un_lock, False, False, 0)

        self.show_all()