Python gi.repository.Gtk.Dialog() Examples

The following are 30 code examples of gi.repository.Gtk.Dialog(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gi.repository.Gtk , or try the search function .
Example #1
Source File: indicator.py    From yandex-disk-indicator with GNU General Public License v3.0 6 votes vote down vote up
def showOutput(self, widget):           # Request for daemon output
            widget.set_sensitive(False)                         # Disable menu item


            def displayOutput(outText, widget):
                # # # NOTE: it is called not from main thread, so it have to add action in main loop queue
                def do_display(outText, widget):
                    # global APPLOGO
                    statusWindow = Gtk.Dialog(_('Yandex.Disk daemon output message'))
                    statusWindow.set_icon(APPLOGO)
                    statusWindow.set_border_width(6)
                    statusWindow.add_button(_('Close'), Gtk.ResponseType.CLOSE)
                    textBox = Gtk.TextView()                            # Create text-box to display daemon output
                    # Set output buffer with daemon output in user language
                    textBox.get_buffer().set_text(outText)
                    textBox.set_editable(False)
                    # Put it inside the dialogue content area
                    statusWindow.get_content_area().pack_start(textBox, True, True, 6)
                    statusWindow.show_all();  statusWindow.run();   statusWindow.destroy()
                    widget.set_sensitive(True)                          # Enable menu item
                idle_add(do_display, outText, widget)

            self.daemon.output(lambda t: displayOutput(t, widget)) 
Example #2
Source File: class_bankaccounts.py    From amir with GNU General Public License v3.0 6 votes vote down vote up
def addNewBank(self, model):
        dialog = Gtk.Dialog(None, None,
                            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_OK, Gtk.ResponseType.OK))
        label = Gtk.Label(label='Bank Name:')
        entry = Gtk.Entry()
        dialog.vbox.pack_start(label, False, False, 0)
        dialog.vbox.pack_start(entry, False, False, 0)
        dialog.show_all()
        result = dialog.run()
        bank_name = entry.get_text()
        if result == Gtk.ResponseType.OK and len(bank_name) != 0:
            iter = model.append()
            model.set(iter, 0, bank_name)
            self.add_bank(bank_name)

        dialog.destroy() 
Example #3
Source File: preferences_window.py    From RAFCON with Eclipse Public License 1.0 6 votes vote down vote up
def _config_chooser_dialog(self, title_text, description):
        """Dialog to select which config shall be exported

        :param title_text: Title text
        :param description: Description
        """
        dialog = Gtk.Dialog(title_text, self.view["preferences_window"],
                            flags=0, buttons=
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
                             Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
        label = Gtk.Label(label=description)
        label.set_padding(xpad=10, ypad=10)
        dialog.vbox.pack_start(label, True, True, 0)
        label.show()
        self._gui_checkbox = Gtk.CheckButton(label="GUI Config")
        dialog.vbox.pack_start(self._gui_checkbox, True, True, 0)
        self._gui_checkbox.show()
        self._core_checkbox = Gtk.CheckButton(label="Core Config")
        self._core_checkbox.show()
        dialog.vbox.pack_start(self._core_checkbox, True, True, 0)
        response = dialog.run()
        dialog.destroy()
        return response 
Example #4
Source File: alttoolbar_plugins.py    From alternative-toolbar with GNU General Public License v3.0 6 votes vote down vote up
def _preferences_button_clicked(self, *args):
        row = self._listbox.get_selected_row()

        widget = self._get_preference_widget(row)

        if not widget:
            return

        if self._has_headerbar:
            dlg = Gtk.Dialog(use_header_bar=True, flags=Gtk.DialogFlags.MODAL)
            dlg.get_header_bar().set_show_close_button(True)
        else:
            dlg = Gtk.Dialog(flags=Gtk.DialogFlags.MODAL)
            dlg.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)

        dlg.props.title = row.plugin.get_name()
        area = dlg.get_content_area()
        area.add(widget)
        dlg.set_resizable(False)
        dlg.run()
        dlg.destroy() 
Example #5
Source File: steam-appmanifest.py    From steam-appmanifest with MIT License 6 votes vote down vote up
def __init__(self, parent, exists, appid, name):
        Gtk.Dialog.__init__(self, "Install appmanifest", parent, 0)
        self.set_default_size(300, 100)

        label0 = Gtk.Label("Install \""+ name +"\"?")
        label1 = Gtk.Label("appmanifest_"+ str(appid) +".acf")

        if exists:
            self.set_title("appmanifest already exists")
            self.add_buttons( "Cancel", Gtk.ResponseType.CANCEL,
                              "Delete anyway", Gtk.ResponseType.OK )
            label0.set_text("This will just remove the appmanifest file")
            label1.set_text("Use Steam to remove all of \""+ name +"\".")
        else:
            self.add_buttons("Cancel", Gtk.ResponseType.CANCEL,
                             "Install", Gtk.ResponseType.OK,)

        self.get_content_area().add(label0)
        self.get_content_area().add(label1)
        self.show_all() 
Example #6
Source File: gtk.py    From encompass with GNU General Public License v3.0 6 votes vote down vote up
def restore_create_dialog():

    # ask if the user wants to create a new wallet, or recover from a seed. 
    # if he wants to recover, and nothing is found, do not create wallet
    dialog = Gtk.Dialog("electrum", parent=None, 
                        flags=Gtk.DialogFlags.MODAL,
                        buttons= ("create", 0, "restore",1, "cancel",2)  )

    label = Gtk.Label("Wallet file not found.\nDo you want to create a new wallet,\n or to restore an existing one?"  )
    label.show()
    dialog.vbox.pack_start(label, True, True, 0)
    dialog.show()
    r = dialog.run()
    dialog.destroy()

    if r==2: return False
    return 'restore' if r==1 else 'create' 
Example #7
Source File: libtmg.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, uistate, data, parent):
        super().__init__(uistate, [], self)
        self.window = Gtk.Dialog()
        self.set_window(self.window, None, _("Database Information"))
        self.window.set_modal(True)
        self.ok = self.window.add_button(_('_OK'), Gtk.ResponseType.OK)
        self.ok.connect('clicked', self.on_ok_clicked)
        self.window.set_position(Gtk.WindowPosition.CENTER)
        self.window.set_default_size(600, 400)
        s = Gtk.ScrolledWindow()
        titles = [
            (_('Setting'), 0, 150),
            (_('Value'), 1, 400)
        ]
        treeview = Gtk.TreeView()
        model = Gtk.ListModel(treeview, titles)
        for key, value in sorted(data.items()):
            model.add((key, str(value),), key)
        s.add(treeview)
        self.window.vbox.pack_start(s, True, True, 0)
        if parent:
            self.window.set_transient_for(parent)
        self.show() 
Example #8
Source File: widgets.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def run(self):
		if TEST_MODE: # Avoid flashing on screen
			for i in self.op:
				pass
		else:
			if not self.op.is_running():
				self.op.run_on_idle()
			self.show_all()
			Gtk.Dialog.run(self) 
Example #9
Source File: templates.py    From rednotebook with GNU General Public License v2.0 5 votes vote down vote up
def on_new_template(self, action):
        dialog = Gtk.Dialog(_("Choose Template Name"))
        dialog.set_transient_for(self.main_window.main_frame)
        dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
        dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
        dialog.set_response_sensitive(Gtk.ResponseType.OK, False)

        # Let user finish by hitting ENTER.
        def respond(widget):
            dialog.response(Gtk.ResponseType.OK)

        def on_text_changed(entry):
            dialog.set_response_sensitive(Gtk.ResponseType.OK, bool(entry.get_text()))

        entry = Gtk.Entry()
        entry.connect("activate", respond)
        # Only allow closing dialog when text is entered.
        entry.connect("changed", on_text_changed)
        entry.set_size_request(300, -1)
        dialog.get_content_area().pack_start(entry, True, True, 0)
        dialog.show_all()
        response = dialog.run()
        dialog.hide()

        if response == Gtk.ResponseType.OK:
            title = entry.get_text()
            selection = self.main_window.day_text_field.get_selection_bounds()
            path = self.get_path(title)
            filesystem.make_file(path, example_text)
            self.enter_template_mode(title, selection) 
Example #10
Source File: two_way_auth.py    From python-eduvpn-client with GNU General Public License v3.0 5 votes vote down vote up
def _choice_window(options, meta, oauth, builder, config_dict, lets_connect):
    # type: (List[str], Metadata, str, Gtk.builder, dict, bool) -> None
    logger.info(u"presenting user with two-factor auth method dialog")
    window = builder.get_object('eduvpn-window')

    # since we can't delete buttons from a dialog we have to create it manually
    # dialog = builder.get_object('2fa-dialog')
    dialog = Gtk.Dialog()
    dialog.set_transient_for(window)
    dialog.set_title("Two factor authentication")
    header = Gtk.Label()
    header.set_markup('<big><b>Two factor authentication</b></big>')
    label = Gtk.Label("Which 2-way authentication method would you like to use?")
    box = dialog.get_content_area()
    box.set_margin_top(8)
    box.set_margin_left(8)
    box.set_margin_right(8)
    box.set_margin_bottom(8)
    box.set_spacing(8)
    box.add(header)
    box.add(label)

    for i, option in enumerate(options):
        dialog.add_button(option, i)

    dialog.show_all()
    index = int(dialog.run())
    dialog.hide()
    if index >= 0:
        meta.username = options[index]
        logger.info(u"user selected '{}'".format(meta.username))
        _enroll(oauth=oauth, meta=meta, builder=builder, config_dict=config_dict, lets_connect=lets_connect) 
Example #11
Source File: widgets.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def do_response(self, id):
		if id == Gtk.ResponseType.OK:
			# Wrap up previous page
			if self._page > -1:
				self._pages[self._page].save_uistate()

			self._uistate.update(self.uistate)

		Dialog.do_response(self, id) 
Example #12
Source File: widgets.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def run(self):
		assert self._pages
		self.set_page(0)
		Dialog.run(self) 
Example #13
Source File: widgets.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, parent, file):
		Dialog.__init__(self, parent, _('Log file'), buttons=Gtk.ButtonsType.CLOSE)
			# T: dialog title for log view dialog - e.g. for Equation Editor
		self.set_default_size(600, 300)
		window, textview = ScrolledTextView(file.read(), monospace=True)
		self.vbox.pack_start(window, True, True, 0) 
Example #14
Source File: steam-appmanifest.py    From steam-appmanifest with MIT License 5 votes vote down vote up
def __init__(self, parent):
        Gtk.Dialog.__init__(self, "Manually install appmanifest", parent, 0,
                           ("Cancel", Gtk.ResponseType.CANCEL,
                            "Install", Gtk.ResponseType.OK))

        self.set_default_size(200, 50)

        appidlabel = Gtk.Label("Game AppID:")
        self.appidentry = Gtk.Entry()

        appidhbox = Gtk.HBox()
        appidhbox.pack_start(appidlabel, False, False, True)
        appidhbox.pack_start(self.appidentry, False, False, True)

        instdirlabel = Gtk.Label("Game directory name:")
        self.instdirentry = Gtk.Entry()

        instdirhbox = Gtk.HBox()
        instdirhbox.pack_start(instdirlabel, False, False, True)
        instdirhbox.pack_start(self.instdirentry, False, False, True)

        vbox = Gtk.VBox()
        vbox.pack_start(appidhbox, False, False, True)
        vbox.pack_start(instdirhbox, False, False, True)

        self.get_content_area().add(vbox)
        self.show_all() 
Example #15
Source File: widgets.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def show_all(self):
		logger.debug('Opening dialog "%s"', self.get_title())
		if not self._registered:
			self._registered = True

		if not TEST_MODE:
			Gtk.Dialog.show_all(self) 
Example #16
Source File: widgets.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def present(self):
		self.show_all()
		if TEST_MODE:
			assert TEST_MODE_RUN_CB, 'Dialog run without test callback'
			TEST_MODE_RUN_CB(self)
		else:
			Gtk.Window.present(self) 
Example #17
Source File: widgets.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def run(self):
		'''Wrapper for C{Gtk.Dialog.run()}, also calls C{show_all()}
		@returns: C{self.result}
		'''
		self.show_all()
		if TEST_MODE:
			assert TEST_MODE_RUN_CB, 'Dialog run without test callback'
			TEST_MODE_RUN_CB(self)
		else:
			while not self.destroyed:
				Gtk.Dialog.run(self)
		return self.result 
Example #18
Source File: widgets.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def present(self):
		self.show_all()
		if TEST_MODE:
			assert TEST_MODE_RUN_CB, 'Dialog run without test callback'
			TEST_MODE_RUN_CB(self)
		else:
			Gtk.Dialog.present(self) 
Example #19
Source File: dialog.py    From ImEditor with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent, title):
        Gtk.Dialog.__init__(self, transient_for=parent)
        self.set_title(title)
        self.set_modal(True)
        self.set_resizable(False)
        self.set_size_request(300, -1)
        self.set_border_width(10)

        self.values = list()

        self.dialog_box = self.get_content_area()
        self.dialog_box.set_spacing(6) 
Example #20
Source File: widgets.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def show_all(self):
		logger.debug('Opening ProgressDialog: %s', self.op.message)
		if not TEST_MODE:
			Gtk.Dialog.show_all(self) 
Example #21
Source File: indicator.py    From yandex-disk-indicator with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, widget, parent, dcofig):   # show current list
            self.dconfig = dcofig
            self.parent = parent
            Gtk.Dialog.__init__(self, title=_('Folders that are excluded from synchronization'),
                                parent=parent, flags=1)
            self.set_icon(APPLOGO)
            self.set_size_request(400, 300)
            self.add_button(_('Add catalogue'),
                            Gtk.ResponseType.APPLY).connect("clicked", self.addFolder, self)
            self.add_button(_('Remove selected'),
                            Gtk.ResponseType.REJECT).connect("clicked", self.deleteSelected)
            self.add_button(_('Close'),
                            Gtk.ResponseType.CLOSE).connect("clicked", self.exitFromDialog)
            self.exList = Gtk.ListStore(bool, str)
            view = Gtk.TreeView(model=self.exList)
            render = Gtk.CellRendererToggle()
            render.connect("toggled", self.lineToggled)
            view.append_column(Gtk.TreeViewColumn(" ", render, active=0))
            view.append_column(Gtk.TreeViewColumn(_('Path'), Gtk.CellRendererText(), text=1))
            scroll = Gtk.ScrolledWindow()
            scroll.add_with_viewport(view)
            self.get_content_area().pack_start(scroll, True, True, 6)
            # Populate list with paths from "exclude-dirs" property of daemon configuration
            self.dirset = [val for val in CVal(self.dconfig.get('exclude-dirs', None))]
            for val in self.dirset:
                self.exList.append([False, val])
            # LOGGER.debug(str(self.dirset))
            self.show_all() 
Example #22
Source File: openweathermap.py    From my-weather-indicator with MIT License 5 votes vote down vote up
def __init__(self, lat=39.36873, lon=-2.417274645879):
        self.images = {}
        self.echo = True
        Gtk.Dialog.__init__(self)
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_title(comun.APP)
        self.set_default_size(900, 600)
        self.set_icon_from_file(comun.ICON)
        self.connect('destroy', self.close_application)
        #
        vbox = Gtk.VBox(spacing=5)
        self.get_content_area().add(vbox)
        hbox1 = Gtk.HBox()
        vbox.pack_start(hbox1, True, True, 0)
        self.scrolledwindow1 = Gtk.ScrolledWindow()
        self.scrolledwindow1.set_policy(
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.scrolledwindow1.set_shadow_type(Gtk.ShadowType.IN)
        hbox1.pack_start(self.scrolledwindow1, True, True, 0)
        self.viewer = WebKit2.WebView()
        self.scrolledwindow1.add(self.viewer)
        self.scrolledwindow1.set_size_request(900, 600)
        self.viewer.connect('load-changed', self.load_changed)
        self.viewer.load_uri('file://' + comun.HTML)
        self.lat = lat
        self.lon = lon
        self.set_focus(self.viewer)
        self.show_all()
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.show_all()
        self.run()
        self.destroy() 
Example #23
Source File: cheatsheet_dialog.py    From bokken with GNU General Public License v2.0 5 votes vote down vote up
def popup_registers(self, widget):
        dialog = Gtk.Dialog('16-bit and 8-bit registers', self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CLOSE,Gtk.ResponseType.CLOSE))
        ui.gtk3.common.set_bokken_icon(dialog)
        reg_img = Gtk.Image()
        reg_img.set_from_file(datafile_path('registers.png'))
        reg_label = Gtk.Label("The four primary general purpose registers (EAX, EBX, ECX and EDX)\nhave 16 and 8 bit overlapping aliases.")
        reg_label.set_alignment(0.1, 0.1)
        reg_label.set_padding (0, 3)
        dialog.vbox.pack_start(reg_label, False, False, 2)
        dialog.vbox.pack_start(reg_img, True, True, 2)
        dialog.show_all()
        dialog.run()
        dialog.destroy() 
Example #24
Source File: cheatsheet_dialog.py    From bokken with GNU General Public License v2.0 5 votes vote down vote up
def popup_stack(self, widget):
        dialog = Gtk.Dialog('The stack', self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CLOSE,Gtk.ResponseType.CLOSE))
        ui.gtk3.common.set_bokken_icon(dialog)
        stack_img = Gtk.Image()
        stack_img.set_from_file(datafile_path('stack.png'))
        dialog.vbox.pack_start(self.create_h1_label("The stack"), False, False, 2)
        dialog.vbox.pack_start(stack_img, True, True, 2)
        dialog.show_all()
        dialog.run()
        dialog.destroy() 
Example #25
Source File: results.py    From runsqlrun with MIT License 5 votes vote down vote up
def __init__(self, parent, data):
        """
        The constructor of this class takes 1 argument:

        :Parameter:
            data
                A Python value to display
        """
        Gtk.Dialog.__init__(self, 'Cell Content', parent,
                            Gtk.DialogFlags.DESTROY_WITH_PARENT,
                            None, use_header_bar=True)
        self.win = parent
        self.set_border_width(10)
        sw = Gtk.ScrolledWindow()
        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        self.vbox.pack_start(sw, True, True, True)

        tv = self._initiate_textview(data)

        tv.set_border_width(10)
        tv.set_editable(False)
        tv.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
        sw.add(tv)

        sw.show_all()
        self.resize(650, 550) 
Example #26
Source File: __init__.py    From runsqlrun with MIT License 5 votes vote down vote up
def assume_password(self):
        if self.connection is None:
            return False
        result = True
        if self.connection.requires_password():
            result = False
            dlg = Gtk.Dialog('Enter password', self.win,
                             Gtk.DialogFlags.DESTROY_WITH_PARENT |
                             Gtk.DialogFlags.MODAL,
                             use_header_bar=True)
            dlg.add_button('_Cancel', Gtk.ResponseType.CANCEL)
            dlg.add_button('_Ok', Gtk.ResponseType.OK)
            dlg.set_default_response(Gtk.ResponseType.OK)
            box = dlg.get_content_area()
            box.set_border_width(12)
            box.set_spacing(6)
            lbl = Gtk.Label()
            lbl.set_markup('Password required for <b>{}</b>.'.format(
                GObject.markup_escape_text(
                    self.connection.get_label())))
            box.pack_start(lbl, True, True, 0)
            entry = Gtk.Entry()
            entry.set_visibility(False)
            entry.set_invisible_char('*')
            entry.connect(
                'activate', lambda *a: dlg.response(Gtk.ResponseType.OK))
            box.pack_start(entry, True, True, 0)
            box.show_all()
            if dlg.run() == Gtk.ResponseType.OK:
                self.connection.set_session_password(entry.get_text())
                result = True
            dlg.destroy()
        return result 
Example #27
Source File: pyspc_gui.py    From pyspc with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):
        Gtk.Dialog.__init__(self, "File Dialog", parent, 0,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_OK, Gtk.ResponseType.OK))
        self.set_default_size(500, 550)
        box = self.get_content_area()

        self.verticalbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
        box.add(self.verticalbox)

        self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)

        from_file = Gtk.Button("From File")
        from_file.connect("clicked", self.on_file)
        from_clipboard = Gtk.Button("Clipboard")
        from_clipboard.connect("clicked", self.on_clipboard)

        hbox1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, homogeneous=True)
        hbox1.pack_start(from_file, True, True, 0)
        hbox1.pack_start(from_clipboard, True, True, 0)
        self.verticalbox.pack_start(hbox1, False, False, 0)

        # Just holding the Place for real treeview widget
        self.scrollable_treelist = Gtk.Label()
        self.verticalbox.pack_start(self.scrollable_treelist, True, True, 0)

        self.show_all() 
Example #28
Source File: test_dialogs.py    From ubuntu-cleaner with GNU General Public License v3.0 5 votes vote down vote up
def test_base(self):
        dialog = BaseDialog()
        self.assertTrue(isinstance(dialog, Gtk.Dialog))
        self.assertEqual(dialog.get_title(), '')
        self.assertEqual(dialog.get_property('text'), '')
        self.assertIsNone(dialog.get_property('secondary-text')) 
Example #29
Source File: automaticaccounting.py    From amir with GNU General Public License v3.0 5 votes vote down vote up
def on_discount_clicked(self, button):
        dialog = Gtk.Dialog("Discount percentage",
                            self.builder.get_object('general'),
                            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_OK, Gtk.ResponseType.OK)
                            )
        adj = Gtk.Adjustment(0, 0, 100, 1, 1)
        spin = Gtk.SpinButton()
        spin.set_adjustment(adj)

        hbox = Gtk.HBox()
        hbox.pack_start(spin, True, True, 0)
        hbox.pack_start(Gtk.Label(' % ', True, True, 0), False, False, 0)
        hbox.show_all()

        dialog.vbox.pack_start(hbox, False, False, 0)

        result = dialog.run()
        if result == Gtk.ResponseType.OK:
            val = spin.get_value()
            total = self.total_credit_entry.get_float()
            discount = (val*total)/100
            self.discount_entry.set_text(str(discount))

        dialog.destroy() 
Example #30
Source File: ui.py    From pympress with GNU General Public License v2.0 5 votes vote down vote up
def adjust_frame_position(self, *args):
        """ Select how to align the frame on screen.
        """
        win_aspect_ratio = float(self.c_win.get_allocated_width()) / self.c_win.get_allocated_height()

        if win_aspect_ratio <= float(self.c_frame.get_property("ratio")):
            prop = "yalign"
        else:
            prop = "xalign"

        val = self.c_frame.get_property(prop)

        button = Gtk.SpinButton()
        button.set_adjustment(Gtk.Adjustment(lower=0.0, upper=1.0, step_increment=0.01))
        button.set_digits(2)
        button.set_value(val)
        button.connect("value-changed", self.update_frame_position, prop)

        popup = Gtk.Dialog(title = _("Adjust alignment of slides in projector screen"), transient_for = self.p_win)
        popup.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)

        box = popup.get_content_area()
        box.add(button)
        popup.show_all()
        response = popup.run()
        popup.destroy()

        # revert if we cancelled
        if response == Gtk.ResponseType.CANCEL:
            self.c_frame.set_property(prop, val)
        else:
            self.config.set('content', prop, str(button.get_value()))