示例#1
0
文件: clicks.py 项目: frostbane/xpra
    def __init__(self):
        self.window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
        self.window.connect("destroy", Gtk.main_quit)
        self.window.set_title("Test Button Events")
        self.window.set_default_size(320, 200)
        self.window.set_border_width(20)
        self.window.set_position(Gtk.WindowPosition.CENTER)
        icon = get_icon_pixbuf("pointer.png")
        if icon:
            self.window.set_icon(icon)

        vbox = Gtk.VBox()
        self.info = Gtk.Label(label="")
        self.show_click_settings()
        GLib.timeout_add(1000, self.show_click_settings)
        vbox.pack_start(self.info, False, False, 0)
        self.label = Gtk.Label(label="Ready")
        vbox.pack_start(self.label, False, False, 0)

        self.eventbox = Gtk.EventBox()
        self.eventbox.connect('button-press-event', self.button_press_event)
        self.eventbox.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
        self.eventbox.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK)
        vbox.pack_start(self.eventbox, True, True, 0)
        self.window.add(vbox)
示例#2
0
def make_window():
    window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
    window.set_title("Text Entry")
    window.connect("destroy", Gtk.main_quit)
    window.set_default_size(320, -1)
    window.set_border_width(40)
    window.set_position(Gtk.WindowPosition.CENTER)
    icon = get_icon_pixbuf("font.png")
    if icon:
        window.set_icon(icon)

    vbox = Gtk.VBox(False, 10)
    window.add(vbox)
    entry = Gtk.Entry()
    entry.set_text("hello")
    vbox.add(entry)

    textview = Gtk.TextView()
    textbuffer = textview.get_buffer()
    textbuffer.set_text("Sample text\nmultiline")
    textview.set_editable(True)
    textview.set_size_request(200, 80)
    vbox.add(textview)

    window.add(entry)
    return window
示例#3
0
 def add_header_bar(self):
     self.menu_helper = WindowMenuHelper(self._client, self)
     hb = Gtk.HeaderBar()
     hb.set_has_subtitle(False)
     hb.set_show_close_button(True)
     hb.props.title = self.get_title()
     if WINDOW_MENU:
         #the icon 'open-menu-symbolic' will be replaced with the window icon
         #when we receive it
         icon = Gio.ThemedIcon(name="preferences-system-windows")
         self.header_bar_image = Gtk.Image.new_from_gicon(
             icon, Gtk.IconSize.BUTTON)
         button = Gtk.Button()
         button.add(self.header_bar_image)
         button.connect("clicked", self.show_window_menu)
         hb.pack_start(button)
     elif WINDOW_ICON:
         #just the icon, no menu:
         pixbuf = get_icon_pixbuf("transparent.png")
         self.header_bar_image = scaled_image(pixbuf, self._icon_size())
         hb.pack_start(self.header_bar_image)
     if WINDOW_XPRA_MENU:
         icon = Gio.ThemedIcon(name="open-menu-symbolic")
         image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
         button = Gtk.Button()
         button.add(image)
         button.connect("clicked", self.show_xpra_menu)
         hb.pack_end(button)
     self.set_titlebar(hb)
示例#4
0
 def __init__(self):
     self.exit_code = None
     super().__init__(type=Gtk.WindowType.TOPLEVEL)
     self.connect("delete_event", self.exit)
     self.add_events(Gdk.EventType.BUTTON_PRESS)
     self.connect("button-press-event", self.exit)
     title = "Xpra %s" % __version__
     self.set_title(title)
     self.set_size_request(W, 40 + 40 * LINES)
     self.set_position(Gtk.WindowPosition.CENTER)
     self.set_decorated(False)
     self.set_opacity(0.9)
     self.set_accept_focus(False)
     self.set_focus_on_map(False)
     self.set_skip_pager_hint(True)
     self.set_skip_taskbar_hint(True)
     if not OSX:
         self.set_type_hint(Gdk.WindowTypeHint.SPLASHSCREEN)
     vbox = Gtk.VBox()
     hbox = Gtk.HBox(homogeneous=False)
     icon = get_icon_pixbuf("xpra.png")
     if icon:
         self.set_icon(icon)
         hbox.pack_start(Gtk.Image.new_from_pixbuf(icon), False, False, 20)
     self.title_label = Gtk.Label(label=title)
     self.title_label.modify_font(Pango.FontDescription("sans 18"))
     hbox.pack_start(self.title_label, True, True, 20)
     vbox.add(hbox)
     self.labels = []
     for i in range(LINES):
         l = Gtk.Label(label=" ")
         l.set_opacity((i + 1) / LINES)
         #l.set_line_wrap(True)
         self.labels.append(l)
         al = Gtk.Alignment(xalign=0, yalign=0.5, xscale=0, yscale=0)
         al.add(l)
         vbox.pack_start(al, True, True, 4)
     self.progress_bar = Gtk.ProgressBar()
     self.progress_bar.set_size_request(320, 30)
     self.progress_bar.set_show_text(False)
     self.progress_bar.set_fraction(0)
     self.progress_timer = None
     self.fade_out_timer = None
     self.exit_timer = None
     vbox.add(self.progress_bar)
     self.timeout_timer = 0
     self.pulse_timer = 0
     self.pulse_counter = 0
     self.current_label_text = None
     self.add(vbox)
     install_signal_handlers(None, self.handle_signal)
     SIGPIPE = getattr(signal, "SIGPIPE", None)
     if SIGPIPE:  #ie: POSIX
         signal.signal(SIGPIPE, self.handle_signal)
     self.opacity = 100
     self.pct = 0
示例#5
0
    def __init__(self):
        self.exit_code = None
        super().__init__()
        self.set_border_width(20)
        self.set_title("Start Desktop Environment")
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_size_request(640, 300)
        icon = get_icon_pixbuf("xpra.png")
        if icon:
            self.set_icon(icon)
        self.connect("delete-event", self.quit)
        add_close_accel(self, self.quit)

        vbox = Gtk.VBox(False, 0)
        vbox.set_spacing(10)

        #self.entry_label = l("Command:")
        #vbox.add(self.entry_label)
        self.desktop_combo = sf(Gtk.ComboBoxText())
        vbox.add(self.desktop_combo)

        # Action buttons:
        hbox = Gtk.HBox(False, 20)
        vbox.pack_start(hbox, False, True, 20)

        def btn(label, tooltip, callback, default=False):
            ib = imagebutton(label,
                             tooltip=tooltip,
                             clicked_callback=callback,
                             icon_size=32,
                             default=default,
                             label_font=Pango.FontDescription("sans 16"))
            hbox.pack_start(ib)
            return ib

        self.cancel_btn = btn("Exit", "", self.quit)
        self.run_btn = btn("Start", "Start the desktop environment",
                           self.run_command)

        vbox.show_all()
        self.add(vbox)
        start_thread(self.load_desktop_session,
                     "load-desktop-sessions",
                     daemon=True)
示例#6
0
def make_window():
    window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
    window.set_size_request(400, 100)
    window.set_position(Gtk.WindowPosition.CENTER)
    window.connect("delete_event", Gtk.main_quit)
    icon = get_icon_pixbuf("font.png")
    if icon:
        window.set_icon(icon)
    entry = Gtk.Entry()
    entry.set_max_length(50)
    entry.connect("changed", change_callback, window)
    title = "Hello"

    if len(sys.argv) > 1:
        title = sys.argv[1]
    entry.set_text(title)
    entry.show()
    window.add(entry)
    return window