Python gi.repository.Gtk.Window() Examples

The following are 30 code examples of gi.repository.Gtk.Window(). 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: uistuff.py    From pychess with GNU General Public License v3.0 6 votes vote down vote up
def makeYellow(box):
    def on_box_expose_event(box, context):
        # box.style.paint_flat_box (box.window,
        #    Gtk.StateType.NORMAL, Gtk.ShadowType.NONE, None, box, "tooltip",
        #    box.allocation.x, box.allocation.y,
        #    box.allocation.width, box.allocation.height)
        pass

    def cb(box):
        tooltip = Gtk.Window(Gtk.WindowType.POPUP)
        tooltip.set_name('gtk-tooltip')
        tooltip.ensure_style()
        tooltipStyle = tooltip.get_style()
        box.set_style(tooltipStyle)
        box.connect("draw", on_box_expose_event)

    onceWhenReady(box, cb) 
Example #2
Source File: graphs.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def make_window(self):
		"""
		Create a window from the figure manager.

		:return: The graph in a new, dedicated window.
		:rtype: :py:class:`Gtk.Window`
		"""
		if self.manager is None:
			self.manager = FigureManager(self.canvas, 0)
		self.navigation_toolbar.destroy()
		self.navigation_toolbar = self.manager.toolbar
		self._menu_item_show_toolbar.set_active(True)
		window = self.manager.window
		window.set_transient_for(self.application.get_active_window())
		window.set_title(self.graph_title)
		return window 
Example #3
Source File: gui_utilities.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def show_dialog_exc_socket_error(error, parent, title=None):
	"""
	Display an error dialog with details regarding a :py:exc:`socket.error`
	exception that has been raised.

	:param error: The exception instance that has been raised.
	:type error: :py:exc:`socket.error`
	:param parent: The parent window that the dialog should belong to.
	:type parent: :py:class:`Gtk.Window`
	:param title: The title of the error dialog that is displayed.
	"""
	title = title or 'Connection Error'
	if isinstance(error, socket.timeout):
		description = 'The connection to the server timed out.'
	elif len(error.args) > 1:
		error_number, error_message = error.args[:2]
		if error_number == 111:
			description = 'The server refused the connection.'
		else:
			description = "Socket error #{0} ({1}).".format((error_number or 'N/A'), error_message)
	return show_dialog(Gtk.MessageType.ERROR, title, parent, secondary_text=description) 
Example #4
Source File: modules.py    From gpt with GNU General Public License v3.0 6 votes vote down vote up
def on_folder_clicked(self):
        Gtk.Window.__init__(self, title=_("Change working directory"))
        dialog = Gtk.FileChooserDialog(_("Choose directory"),
                                       self,
                                       Gtk.FileChooserAction.SELECT_FOLDER,
                                       (Gtk.STOCK_CANCEL,
                                        Gtk.ResponseType.CANCEL,
                                        _("Apply"),
                                        Gtk.ResponseType.OK,
                                        )
                                       )
        dialog.set_default_size(800, 400)
        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            self.selectedfolder = dialog.get_filename()
        elif response == Gtk.ResponseType.CANCEL:
            self.selectedfolder = cli.stdir

        dialog.destroy() 
Example #5
Source File: DownloadMedia.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, dbstate, user, options_class, name, callback=None):
        uistate = user.uistate
        self.user = user
        self.label = _('Download media')
        ManagedWindow.__init__(self, uistate, [], self.__class__)
        self.set_window(Gtk.Window(), Gtk.Label(), '')
        tool.Tool.__init__(self, dbstate, options_class, name)

        self.num_downloads = 0
        dialog = self.display()
        response = dialog.run()
        dialog.destroy()

        if response == Gtk.ResponseType.ACCEPT:
            self.on_ok_clicked()
            if hasattr(self.user.uistate, 'window'):
                parent_window = self.user.uistate.window
            else:
                parent_window = None
            OkDialog(_('Media downloaded'),
                     _("%d media files downloaded") % self.num_downloads,
                     parent=parent_window)
        self.close() 
Example #6
Source File: backend_gtk3.py    From Computable with MIT License 6 votes vote down vote up
def error_msg_gtk(msg, parent=None):
    if parent is not None: # find the toplevel Gtk.Window
        parent = parent.get_toplevel()
        if not parent.is_toplevel():
            parent = None

    if not is_string_like(msg):
        msg = ','.join(map(str,msg))

    dialog = Gtk.MessageDialog(
        parent         = parent,
        type           = Gtk.MessageType.ERROR,
        buttons        = Gtk.ButtonsType.OK,
        message_format = msg)
    dialog.run()
    dialog.destroy() 
Example #7
Source File: backend_gtk3.py    From Mastering-Elasticsearch-7.0 with MIT License 6 votes vote down vote up
def error_msg_gtk(msg, parent=None):
    if parent is not None:  # find the toplevel Gtk.Window
        parent = parent.get_toplevel()
        if not parent.is_toplevel():
            parent = None

    if not isinstance(msg, str):
        msg = ','.join(map(str, msg))

    dialog = Gtk.MessageDialog(
        parent         = parent,
        type           = Gtk.MessageType.ERROR,
        buttons        = Gtk.ButtonsType.OK,
        message_format = msg)
    dialog.run()
    dialog.destroy() 
Example #8
Source File: backend_gtk3.py    From matplotlib-4-abaqus with MIT License 6 votes vote down vote up
def error_msg_gtk(msg, parent=None):
    if parent is not None: # find the toplevel Gtk.Window
        parent = parent.get_toplevel()
        if not parent.is_toplevel():
            parent = None

    if not is_string_like(msg):
        msg = ','.join(map(str,msg))

    dialog = Gtk.MessageDialog(
        parent         = parent,
        type           = Gtk.MessageType.ERROR,
        buttons        = Gtk.ButtonsType.OK,
        message_format = msg)
    dialog.run()
    dialog.destroy() 
Example #9
Source File: editexifmetadata.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
def thumbnail_view(self, _object):
        """
        will allow a display area for a thumbnail pop-up window.
        """
        tip = _("Click Close to close this Thumbnail View Area.")

        parent = self.gui.get_container_widget().get_toplevel()
        self.tbarea = Gtk.Window(type=Gtk.WindowType.TOPLEVEL,
                                 transient_for=parent)
        self.tbarea.tooltip = tip
        self.tbarea.set_title(_("Thumbnail View Area"))

        pbloader, width, height = self.__get_thumbnail_data()
        if pbloader:
            self.tbarea.set_default_size((width + 40), (height + 40))

            self.tbarea.set_border_width(10)
            self.tbarea.connect('destroy', lambda w: self.tbarea.destroy())

            new_vbox = self.build_thumbnail_gui(pbloader, width, height)
            self.tbarea.add(new_vbox)
            self.tbarea.show()
        else:
            self.deactivate_buttons(["Thumbnail"])
            lambda w: self.tbarea.destroy() 
Example #10
Source File: backend_gtk3.py    From neural-network-animation with MIT License 6 votes vote down vote up
def error_msg_gtk(msg, parent=None):
    if parent is not None: # find the toplevel Gtk.Window
        parent = parent.get_toplevel()
        if not parent.is_toplevel():
            parent = None

    if not is_string_like(msg):
        msg = ','.join(map(str,msg))

    dialog = Gtk.MessageDialog(
        parent         = parent,
        type           = Gtk.MessageType.ERROR,
        buttons        = Gtk.ButtonsType.OK,
        message_format = msg)
    dialog.run()
    dialog.destroy() 
Example #11
Source File: RemarkableWindow.py    From Remarkable with MIT License 6 votes vote down vote up
def insert_table(self, widget):
        self.insert_window_table = Gtk.Window()
        self.insert_window_table.set_title("Insert Table")
        self.insert_window_table.set_resizable(True)
        self.insert_window_table.set_border_width(6)
        self.insert_window_table.set_default_size(300, 250)
        self.insert_window_table.set_position(Gtk.WindowPosition.CENTER)
        vbox = Gtk.VBox()
        label_n_rows = Gtk.Label("Number of Rows:")
        self.entry_n_rows = Gtk.Entry()
        label_n_columns = Gtk.Label("Number of Columns")
        self.entry_n_columns = Gtk.Entry()
        vbox.pack_start(label_n_rows, self, False, False)
        vbox.pack_start(self.entry_n_rows, self, False, False)
        vbox.pack_start(label_n_columns, self, False, False)
        vbox.pack_start(self.entry_n_columns, self, False, False)
        button = Gtk.Button("Insert Table")
        vbox.pack_end(button, self, False, False)
        self.insert_window_table.add(vbox)
        self.insert_window_table.show_all()
        button.connect("clicked", self.insert_table_cmd, self.insert_window_table) 
Example #12
Source File: RemarkableWindow.py    From Remarkable with MIT License 6 votes vote down vote up
def on_menuitem_custom_activate(self, widget):
        self.custom_window = Gtk.Window()
        self.custom_window.set_default_size(640, 480)
        self.custom_window.set_position(Gtk.WindowPosition.CENTER)
        self.custom_window.set_title("Custom CSS")

        self.custom_vbox = Gtk.VBox()
        self.custom_scroller = Gtk.ScrolledWindow()
        self.custom_button = Gtk.Button("Apply")
        self.custom_vbox.pack_end(self.custom_button, False, False, 0)
        self.custom_text_view = Gtk.TextView()
        self.custom_text_buffer = Gtk.TextBuffer()
        self.custom_text_buffer.set_text(self.custom_css)
        self.custom_text_view.set_buffer(self.custom_text_buffer)
        self.custom_scroller.add(self.custom_text_view)
        self.custom_vbox.pack_start(self.custom_scroller, True, True, 0)
        self.custom_window.add(self.custom_vbox)
        self.custom_window.show_all()
        self.custom_button.connect("clicked", self.apply_custom_css, self.custom_window, self.custom_text_buffer) 
Example #13
Source File: widgets.py    From nautilus-folder-icons with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, folders):
        GObject.GObject.__init__(self)
        Thread.__init__(self)
        Gtk.Window.__init__(self)
        self.connect("delete-event", self._close_window)
        # Here i assume that all folders got the same icon...
        self._folders = folders
        self.model = []
        self._flowbox = Gtk.FlowBox()

        # Threading stuff
        self.setDaemon(True)
        self.run()

        # Window configurations
        self.set_default_size(650, 500)
        self.set_size_request(650, 500)
        self.set_resizable(True)
        self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
        self.connect("key-press-event", self._on_key_press)

        # Widgets & Accelerators
        self._build_header_bar()
        self._build_content()
        self._setup_accels() 
Example #14
Source File: slider_win.py    From volctl with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, volctl):
        self.volctl = volctl
        self._win = Gtk.Window(type=Gtk.WindowType.POPUP)
        self._win.connect("enter-notify-event", self._cb_enter_notify)
        self._win.connect("leave-notify-event", self._cb_leave_notify)
        self._grid = Gtk.Grid()
        self._grid.set_column_spacing(2)
        self._grid.set_row_spacing(self.SPACING)
        self._frame = Gtk.Frame()
        self._frame.set_shadow_type(Gtk.ShadowType.OUT)
        self._frame.add(self._grid)
        self._win.add(self._frame)

        # gui objects by index
        self._sink_scales = {}
        self._sink_input_scales = {}

        self._create_sliders()
        self._win.show_all()
        self._set_position()

        # timeout
        self._timeout = None
        self._enable_timeout() 
Example #15
Source File: runtime_config.py    From RAFCON with Eclipse Public License 1.0 6 votes vote down vote up
def store_widget_properties(self, widget, widget_name):
        """Sets configuration values for widgets

        If the widget is a window, then the size and position are stored. If the widget is a pane, then only the
        position is stored. If the window is maximized the last insert position before being maximized is keep in the
        config and the maximized flag set to True. The maximized state and the last size and position are strictly
        separated by this.

        :param widget: The widget, for which the position (and possibly the size) will be stored.
        :param widget_name: The window or widget name of the widget, which constitutes a part of its key in the
        configuration file.
        """
        if isinstance(widget, Gtk.Window):
            maximized = bool(widget.is_maximized())
            self.set_config_value('{0}_MAXIMIZED'.format(widget_name), maximized)
            if maximized:
                return
            size = widget.get_size()
            self.set_config_value('{0}_SIZE'.format(widget_name), tuple(size))
            position = widget.get_position()
            self.set_config_value('{0}_POS'.format(widget_name), tuple(position))
        else:  # Gtk.Paned
            position = widget.get_position()
            self.set_config_value('{0}_POS'.format(widget_name), position) 
Example #16
Source File: single_widget_window.py    From RAFCON with Eclipse Public License 1.0 6 votes vote down vote up
def __init__(self, view_class, width=500, height=500, title=None, pos=None):
        View.__init__(self)

        w = Gtk.Window()
        if title is None:
            w.set_title(str(view_class))
        else:
            w.set_title(title)
        w.resize(width=width, height=height)
        if pos is not None:
            w.set_position(pos)
        self.widget_view = view_class()
        w.add(self.widget_view.get_top_widget())
        w.show_all()

        self['main_frame'] = self.widget_view
        self.top = 'main_frame'
        self['main_window'] = w 
Example #17
Source File: app.py    From vimiv with MIT License 6 votes vote down vote up
def _init_widgets(self):
        """Create all the other widgets and add them to the class."""
        self["eventhandler"] = EventHandler(self)
        self["transform"] = Transform(self)
        self["commandline"] = CommandLine(self)
        self["tags"] = TagHandler(self)
        self["mark"] = Mark(self)
        self["clipboard"] = ClipboardHandler(self)
        self["statusbar"] = Statusbar(self)
        self["completions"] = Completion(self)
        self["slideshow"] = Slideshow(self)
        self["main_window"] = MainWindow(self)
        self["image"] = self["main_window"].image
        self["thumbnail"] = self["main_window"].thumbnail
        self["library"] = Library(self)
        self["manipulate"] = Manipulate(self)
        self["information"] = Information()
        self["window"] = Window(self)
        # Generate completions as soon as commands exist
        self["commandline"].init_commands()
        self["completions"].generate_commandlist()
        self["log"] = Log(self) 
Example #18
Source File: ImageMenu.py    From pychess with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, image, child):
        GObject.GObject.__init__(self)
        self.add(image)

        self.subwindow = Gtk.Window()
        self.subwindow.set_transient_for(mainwindow())
        self.subwindow.set_decorated(False)
        self.subwindow.set_resizable(False)
        self.subwindow.set_type_hint(Gdk.WindowTypeHint.DIALOG)
        self.subwindow.add(child)
        self.subwindow.connect_after("draw", self.__sub_onExpose)
        self.subwindow.connect("button_press_event", self.__sub_onPress)
        # self.subwindow.connect("motion_notify_event", self.__sub_onMotion)
        # self.subwindow.connect("leave_notify_event", self.__sub_onMotion)
        # self.subwindow.connect("delete-event", self.__sub_onDelete)
        self.subwindow.connect("focus-out-event", self.__sub_onFocusOut)
        child.show_all()

        self.setOpen(False)
        self.connect("button_press_event", self.__onPress) 
Example #19
Source File: RemarkableWindow.py    From Remarkable with MIT License 5 votes vote down vote up
def insert_link(self, widget):
        self.insert_window_link = Gtk.Window()
        self.insert_window_link.set_title("Insert Link")
        self.insert_window_link.set_resizable(True)
        self.insert_window_link.set_border_width(6)
        self.insert_window_link.set_default_size(350, 250)
        self.insert_window_link.set_position(Gtk.WindowPosition.CENTER)
        vbox = Gtk.VBox()
        label_alt_text = Gtk.Label("Alt Text:")
        self.entry_alt_text = Gtk.Entry()
        label_url = Gtk.Label("Url:")
        self.entry_url = Gtk.Entry()
        vbox.pack_start(label_alt_text, self, False, False)
        vbox.pack_start(self.entry_alt_text, self, False, False)
        vbox.pack_start(label_url, self, False, False)
        vbox.pack_start(self.entry_url, self, False, False)
        button = Gtk.Button("Insert Link")
        vbox.pack_end(button, self, False, False)

        # Use highligted text as the default "alt text"
        if self.text_buffer.get_has_selection():
            start, end = self.text_buffer.get_selection_bounds()
            text = self.text_buffer.get_text(start, end, True)
            self.entry_alt_text.set_text(text)

        self.insert_window_link.add(vbox)
        self.insert_window_link.show_all()
        button.connect("clicked", self.insert_link_cmd, self.insert_window_link) 
Example #20
Source File: RemarkableWindow.py    From Remarkable with MIT License 5 votes vote down vote up
def insert_image(self, widget):
        self.insert_window_image = Gtk.Window()
        self.insert_window_image.set_title("Insert Image")
        self.insert_window_image.set_resizable(True)
        self.insert_window_image.set_border_width(6)
        self.insert_window_image.set_default_size(300, 250)
        self.insert_window_image.set_position(Gtk.WindowPosition.CENTER)
        vbox = Gtk.VBox()
        label_alt_text = Gtk.Label("Alt Text:")
        self.entry_alt_text_i = Gtk.Entry()
        label_title = Gtk.Label("Title:")
        self.entry_title_i = Gtk.Entry()
        label_url = Gtk.Label("Path/Url:")
        self.entry_url_i = Gtk.Entry()
        vbox.pack_start(label_alt_text, self, False, False)
        vbox.pack_start(self.entry_alt_text_i, self, False, False)
        vbox.pack_start(label_title, self, False, False)
        vbox.pack_start(self.entry_title_i, self, False, False)
        vbox.pack_start(label_url, self, False, False)
        self.hbox_url = Gtk.HBox()
        self.hbox_url.pack_start(self.entry_url_i, self, True, False)
        self.path_file_button = Gtk.FileChooserButton(title= "Select an image")
        self.path_file_button.connect("file-set", self.file_chooser_button_clicked)
        self.hbox_url.pack_start(self.path_file_button, self, False, False)
        vbox.pack_start(self.hbox_url, self, False, False)
        button = Gtk.Button("Insert Image")
        vbox.pack_end(button, self, False, False)
        self.insert_window_image.add(vbox)
        self.insert_window_image.show_all()
        button.connect("clicked", self.insert_image_cmd, self.insert_window_image) 
Example #21
Source File: backend_gtk3.py    From neural-network-animation with MIT License 5 votes vote down vote up
def configure_subplots(self, button):
        toolfig = Figure(figsize=(6,3))
        canvas = self._get_canvas(toolfig)
        toolfig.subplots_adjust(top=0.9)
        tool =  SubplotTool(self.canvas.figure, toolfig)

        w = int (toolfig.bbox.width)
        h = int (toolfig.bbox.height)


        window = Gtk.Window()
        try:
            window.set_icon_from_file(window_icon)
        except (SystemExit, KeyboardInterrupt):
            # re-raise exit type Exceptions
            raise
        except:
            # we presumably already logged a message on the
            # failure of the main plot, don't keep reporting
            pass
        window.set_title("Subplot Configuration Tool")
        window.set_default_size(w, h)
        vbox = Gtk.Box()
        vbox.set_property("orientation", Gtk.Orientation.VERTICAL)
        window.add(vbox)
        vbox.show()

        canvas.show()
        vbox.pack_start(canvas, True, True, 0)
        window.show() 
Example #22
Source File: application_window.py    From kano-toolset with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, title="Application", width=None, height=None):
        Gtk.Window.__init__(self, title=title)

        self.set_decorated(False)
        self.set_resizable(False)

        screen = Gdk.Screen.get_default()
        self._win_width = width
        if width <= 1:
            self._win_width = int(screen.get_width() * width)

        self._win_height = height
        if height <= 1:
            self._win_height = int(screen.get_height() * height)
        self.set_size_request(self._win_width, self._win_height)

        self.set_position(Gtk.WindowPosition.CENTER)
        self.connect('delete-event', Gtk.main_quit)

        apply_common_to_screen()

        self._overlay = Gtk.Overlay()
        self.add(self._overlay)

        self._blur = Gtk.EventBox()
        self._blur.get_style_context().add_class('blur')

        self._blurred = False

        # TODO: Maybe handle the taskbar here to avoid even more code duplication? 
Example #23
Source File: kano_combobox.py    From kano-toolset with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        Gtk.Window.__init__(self)
        self.combo_box = KanoComboBox()

        self.add(self.combo_box)
        self.combo_box.set_items(["item1", "item2", "item3", "item4", "item5", "item6", "item7", "item8"])
        self.combo_box.set_selected_item_index(0)

        self.connect("delete-event", Gtk.main_quit)

        self.show_all() 
Example #24
Source File: kano_progress.py    From kano-toolset with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, pulse=True, title="", rate=0.01):
        apply_colours_to_screen()
        apply_styling_to_screen(self.CSS_PATH)

        ProgressBar.__init__(self, pulse, rate)
        self.get_style_context().add_class("KanoProgressBar")

        self.win = Gtk.Window()
        self.win.get_style_context().add_class("KanoProgressBar")
        self.win.set_decorated(False)
        self.win.set_resizable(False)
        self.win.set_position(Gtk.WindowPosition.CENTER)
        self.win.connect("delete-event", Gtk.main_quit)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.win.add(box)

        label = Gtk.Label(title)
        label.set_padding(10, 10)
        label.get_style_context().add_class("KanoProgressBar")
        box.pack_start(label, False, False, 5)
        box.pack_start(self, False, False, 0) 
Example #25
Source File: buttons.py    From kano-toolset with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        Gtk.Window.__init__(self)
        self.box = Gtk.Box()
        self.add(self.box)

        colours = ["red", "blue", "green", "orange"]
        for c in colours:
            button = KanoButton("hello", color=c)
            self.box.pack_start(button, False, False, 0)
            button.connect("button-release-event", self.spinner_test)

        self.connect("delete-event", Gtk.main_quit)
        self.show_all() 
Example #26
Source File: gnupg.py    From Authenticator with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, filename):
        Gtk.Window.__init__(self)
        self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
        self.set_size_request(400, 200)
        self.set_title(_("GPG paraphrase"))
        self.resize(400, 200)
        self._filename = filename
        self._build_widgets() 
Example #27
Source File: splash_screen.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def __init__(self, width=530, height=350, contains_image=False):
        # init Gtk.Window with type popup
        super(SplashScreen, self).__init__(type=Gtk.WindowType.POPUP)

        # index for the image rotator
        self.image_index = 0

        # Set the title to rafcon so it is detectable in taskbars
        # set width and height to parameter values and position the window in the center
        self.set_title('RAFCON')
        self.set_default_size(width, height)
        self.set_position(Gtk.WindowPosition.CENTER)

        main_vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
        self.add(main_vbox)
        self.image = Gtk.Image()
        # If an img path was defined, create a gtk img and fill it from a pixelbuffer which is created from the
        # set file path
        if contains_image:
            main_vbox.pack_start(self.image, True, True, 0)

        # add label to display text, the text can be changed by the text() method.
        # Align it in the middle of the gtk window
        self.label = Gtk.Label(label="")
        self.label.set_xalign(0.5)
        self.label.set_yalign(0.5)
        main_vbox.pack_start(self.label, False, True, 10)
        main_vbox.set_spacing(0)

        if not os.getenv("RAFCON_START_MINIMIZED", False):
            self.show_all() 
Example #28
Source File: dialog.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def __init__(self, markup_text=None,
                 callback=None, callback_args=(),
                 message_type=Gtk.MessageType.WARNING, flags=Gtk.DialogFlags.MODAL, parent=None,
                 width=-1, standalone=False, title="RAFCON", height=-1):
        modal_flag = destroy_with_parent = False
        if flags is Gtk.DialogFlags.MODAL:
            modal_flag = destroy_with_parent = True
        if parent is True:
            transient_for = get_root_window()
        elif isinstance(parent, Gtk.Window):
            transient_for = parent
        else:
            transient_for = None

        # See https://stackoverflow.com/a/11589779 for how to pass parameters to GTK constructors
        if self.__class__.__name__ == "RAFCONMessageDialog":
            super(RAFCONMessageDialog, self).__init__(message_type=message_type, buttons=Gtk.ButtonsType.OK,
                                                      modal=modal_flag, destroy_with_parent=destroy_with_parent,
                                                      transient_for=transient_for)
        else:
            super(RAFCONMessageDialog, self).__init__(message_type=message_type,
                                                      modal=modal_flag, destroy_with_parent=destroy_with_parent,
                                                      transient_for=transient_for)
        self.set_title(title)

        self.set_default_size(width, height)

        if isinstance(markup_text, string_types):
            from xml.sax.saxutils import escape
            self.set_markup(escape(str(markup_text)))
        else:
            logger.debug("The specified message '{1}' text is not a string, but {0}".format(markup_text,
                                                                                            type(markup_text)))
        if callback:
            self.add_callback(callback, *callback_args)

        self.show_grab_focus_and_run(standalone) 
Example #29
Source File: preferences_window.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def _on_delete_event(window, event):
        """Called when the window gets destroyed

        Hides the window.

        :param Gtk.Window window: The window
        :param Gdk.Event event: Event data
        """
        window.hide()
        return True 
Example #30
Source File: authentication.py    From networkmgr with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, ssid, bssid, wificard):
        self.wificard = wificard
        self.ssid = ssid
        self.bssid = bssid
        self.window = Gtk.Window()
        self.window.set_title("wi-Fi Network Authetification Required")
        self.window.set_border_width(0)
        # self.window.set_position(Gtk.WIN_POS_CENTER)
        self.window.set_size_request(500, 200)
        # self.window.set_icon_from_file("/usr/local/etc/gbi/logo.png")
        box1 = Gtk.VBox(False, 0)
        self.window.add(box1)
        box1.show()
        box2 = Gtk.VBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, True, True, 0)
        box2.show()
        # Creating MBR or GPT drive
        title = "Authetification required by %s Wi-Fi Network" % ssid
        label = Gtk.Label("<b><span size='large'>%s</span></b>" % title)
        label.set_use_markup(True)
        pwd_label = Gtk.Label("Password:")
        self.password = Gtk.Entry()
        self.password.set_visibility(False)
        check = Gtk.CheckButton("Show password")
        check.connect("toggled", self.on_check)
        table = Gtk.Table(1, 2, True)
        table.attach(label, 0, 5, 0, 1)
        table.attach(pwd_label, 1, 2, 2, 3)
        table.attach(self.password, 2, 4, 2, 3)
        table.attach(check, 2, 4, 3, 4)
        box2.pack_start(table, False, False, 0)
        box2 = Gtk.HBox(False, 10)
        box2.set_border_width(5)
        box1.pack_start(box2, False, True, 0)
        box2.show()
        # Add create_scheme button
        box2.pack_end(self.button(), True, True, 5)
        self.window.show_all()