当前位置: 首页>>代码示例>>Python>>正文


Python repository.Gdk方法代码示例

本文整理汇总了Python中gi.repository.Gdk方法的典型用法代码示例。如果您正苦于以下问题:Python repository.Gdk方法的具体用法?Python repository.Gdk怎么用?Python repository.Gdk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository的用法示例。


在下文中一共展示了repository.Gdk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: is_quartz

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def is_quartz():
    """
    Tests to see if Python is currently running with gtk and
    windowing system is Mac OS-X's "quartz".
    """
    if mac():
        try:
            import gi
            gi.require_version('Gtk', '3.0')
            gi.require_version('Gdk', '3.0')
            from gi.repository import Gtk
            from gi.repository import Gdk
        except ImportError:
            return False
        return Gdk.Display.get_default().__class__.__name__.endswith("QuartzDisplay")
    return False 
开发者ID:GenealogyCollective,项目名称:gprime,代码行数:18,代码来源:constfunc.py

示例2: change_folder_icon

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def change_folder_icon(folders, window):
    """Change default folder icon."""
    from widgets import FolderIconChooser

    def set_icon(icon_window, icon_name):
        """Set the folder icon & refresh Nautilus's view."""
        for folder in folders:
            set_default_icon(folder, icon_name)
        # Refresh Nautilus (doesn't work on Nemo...)
        if window.has_action("reload"):
            action = window.lookup_action("reload")
            action.emit("activate", None)
        icon_window.emit("delete-event", Gdk.Event.new(Gdk.EventType.DELETE))
    # Show Icon Chooser window
    icon_window = FolderIconChooser(folders)
    icon_window.set_transient_for(window)
    icon_window.connect("selected", set_icon)
    icon_window.show_all() 
开发者ID:bilelmoussaoui,项目名称:nautilus-folder-icons,代码行数:20,代码来源:utils.py

示例3: __init__

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def __init__(self):
        Gtk.IconView.__init__(self)

        # Add style class
        style_context = self.get_style_context()
        style_context.add_class("WidgetChooser")

        self.set_text_column(0)
        self.set_pixbuf_column(1)
        self.set_item_width(130)
        self.set_columns(1)

        self.model = Gtk.ListStore(str, GdkPixbuf.Pixbuf, str)
        self.set_model(self.model)

        # Enable DnD
        self.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, [], Gdk.DragAction.COPY)
        self.connect("drag-data-get", self.on_drag_data_get)
        self.connect("drag-begin", self.on_drag_begin)
        self.connect("drag-end", self.on_drag_end)
        self.drag_source_set_target_list(None)
        self.drag_source_add_text_targets()
        self.drag = False

        self.connect('focus-out-event', self.on_focus_out) 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:27,代码来源:widget_chooser.py

示例4: __init__

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def __init__(self):
        Gtk.Fixed.__init__(self)

        # Set up drag 'n drop
        self.drag_dest_set(Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY)
        self.connect("drag-data-received", self.on_drag_data_received)

        self.drag_dest_set_target_list(None)
        self.drag_dest_add_text_targets()

        # Initial event positions
        self.initial_x = 0
        self.initial_y = 0

        # Initial child properties
        self.initial_pos_x = 0
        self.initial_pos_y = 0
        self.initial_w = 0
        self.initial_h = 0

        # Maximum change in size/pos
        self.dx_max = 0
        self.dy_max = 0 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:25,代码来源:widget_area.py

示例5: has_display

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def has_display():
    """
    Tests to see if Python is currently running with gtk
    """
    # FIXME: currently, Gtk.init_check() requires all strings
    # in argv, and we might have unicode.
    temp, sys.argv = sys.argv, sys.argv[:1]
    try:
        import gi
        gi.require_version('Gtk', '3.0')
        gi.require_version('Gdk', '3.0')
        from gi.repository import Gtk
        from gi.repository import Gdk
    except ImportError:
        return False

    try:
        test = Gtk.init_check(temp) and \
            Gdk.Display.get_default()
        sys.argv = temp
        return bool(test)
    except:
        sys.argv = temp
        return False

# A couple of places add menu accelerators using <alt>, which doesn't
# work with Gtk-quartz. <Meta> is the usually correct replacement, but
# in one case the key is a number, and <meta>number is used by Spaces
# (a mac feature), so we'll use control instead. 
开发者ID:GenealogyCollective,项目名称:gprime,代码行数:31,代码来源:constfunc.py

示例6: on_realize

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def on_realize(self, *_):
        monitor = Gdk.Display.get_primary_monitor(Gdk.Display.get_default())
        scale = monitor.get_scale_factor()
        monitor_width = monitor.get_geometry().width / scale
        monitor_height = monitor.get_geometry().height / scale
        width = self.get_preferred_width()[0]
        height = self.get_preferred_height()[0]
        self.move((monitor_width - width)/2, (monitor_height - height)/2) 
开发者ID:atareao,项目名称:lplayer,代码行数:10,代码来源:basedialog.py

示例7: build_monitors_from_gdk

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def build_monitors_from_gdk():
    monitors = []
    try:
        display = Gdk.Display.get_default()
        num_monitors = display.get_n_monitors()
        for i in range(0, num_monitors):
            monitor = display.get_monitor(i)
            monitor_rect = monitor.get_geometry()
            monitors.append(Monitor(
                monitor_rect.width,
                monitor_rect.height,
                monitor.get_scale_factor(),
                monitor_rect.x,
                monitor_rect.y,
                i,
                'Monitor {0} ({1})'.format(
                    i,
                    monitor.get_model()
                ),
                monitor.is_primary()
            ))
    except Exception as e:
        print('Error: error parsing monitors (Gdk)')
        import traceback
        traceback.print_exc()
        monitors = None
    return monitors 
开发者ID:GabMus,项目名称:HydraPaper,代码行数:29,代码来源:monitor_parser.py

示例8: is_active_window_skipped

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def is_active_window_skipped(pre_break):
    """
    Check for full-screen applications.
    This method must be executed by the main thread. If not, it will cause random failure.
    """
    logging.info('Searching for full-screen application')
    screen = Gdk.Screen.get_default()

    active_window = screen.get_active_window()
    if active_window:
        active_xid = str(active_window.get_xid())
        cmdlist = ['xprop', '-root', '-notype', '-id',
                   active_xid, 'WM_CLASS', '_NET_WM_STATE']

        try:
            stdout = subprocess.check_output(cmdlist).decode('utf-8')
        except subprocess.CalledProcessError:
            logging.warning('Error in finding full-screen application')
        else:
            if stdout:
                is_fullscreen = 'FULLSCREEN' in stdout
                # Extract the process name
                process_names = re.findall('"(.+?)"', stdout)
                if process_names:
                    process = process_names[1].lower()
                    if process in skip_break_window_classes:
                        return True
                    elif process in take_break_window_classes:
                        if is_fullscreen and unfullscreen_allowed and not pre_break:
                            try:
                                active_window.unfullscreen()
                            except BaseException:
                                logging.error(
                                    'Error in unfullscreen the window ' + process)
                        return False

                return is_fullscreen

    return False 
开发者ID:slgobinath,项目名称:SafeEyes,代码行数:41,代码来源:plugin.py

示例9: resolution

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def resolution(self):
        s = Gdk.Screen.get_default()
        return '%dx%d' % (s.get_width(), s.get_height()) 
开发者ID:atareao,项目名称:cpu-g,代码行数:5,代码来源:investigator.py

示例10: pressed

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def pressed(self, widget, event):
        if not self.use_default_controls:
            return
        button1 = event.button == 1
        button2 = event.button == 2
        button3 = event.button == 3
        if button1:
            self.select_prime(event.x, event.y)  # select G-Code element

        if button3 and (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS):
            self.clear_live_plotter()
        elif button1 or button2 or button3:
            self.startZoom(event.y)
            self.recordMouse(event.x, event.y) 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:16,代码来源:gremlin3d.py

示例11: scroll

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def scroll(self, widget, event):
        if not self.use_default_controls: return
        if event.direction == Gdk.ScrollDirection.UP:
            self.zoomin()
        elif event.direction == Gdk.ScrollDirection.DOWN:
            self.zoomout() 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:8,代码来源:gremlin3d.py

示例12: on_window_state_event

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def on_window_state_event(self, widget, event):
        # Listen to state event and track window state
        if self.window_fullscreen != bool(event.new_window_state & Gdk.WindowState.FULLSCREEN):
            self.window_fullscreen = bool(event.new_window_state & Gdk.WindowState.FULLSCREEN)
            self.on_fullscreen_state_changed(self.window_fullscreen)
        if self.window_maximized != bool(event.new_window_state & Gdk.WindowState.MAXIMIZED):
            self.window_maximized = bool(event.new_window_state & Gdk.WindowState.MAXIMIZED)
            self.on_maximized_state_changed(self.window_maximized) 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:10,代码来源:header_bar.py

示例13: get_monitors

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def get_monitors():

    monitors_list = []

    #~ try:
        #~ x = os.environ['WAYLAND_DISPLAY']
        #~ session_type = 'wayland'
    #~ except KeyError:
        #~ session_type = 'x11'

    #~ if session_type == 'x11':

        # Use GTK

        # Doesn't work in distros that use gtk < 3.22
        # Doesn't work with Wayland (?)
        # => disabled for now

        #~ display_manager = Gdk.DisplayManager.get()
        #~ display = Gdk.DisplayManager.get_default_display(display_manager)
        #~ n_monitors = display.get_n_monitors()

        #~ for monitor_index in range(n_monitors):
            #~ monitor = display.get_monitor(monitor_index)

            #~ model = monitor.get_model()
            #~ geometry = monitor.get_geometry()
            #~ monitors_list.append(model + ' ' + str(geometry.width) + 'x' + str(geometry.height))

            #~ if monitor.is_primary():
                #~ monitor_primary = model + ' ' + str(geometry.width) + 'x' + str(geometry.height)

    #~ else:

    # Use xrandr

    proc = subprocess.Popen(['xrandr'],stdout=subprocess.PIPE)
    for line in proc.stdout.readlines():

        if re.compile(r'\b({0})\b'.format('connected'), flags=re.IGNORECASE).search(str(line)):
            if 'primary' in line.decode('utf-8'):
                monitors_list.append(line.decode('utf-8').split(' ')[0] + ' ' + line.decode('utf-8').split(' ')[3].split('+')[0])
            else:
                monitors_list.append(line.decode('utf-8').split(' ')[0] + ' ' + line.decode('utf-8').split(' ')[2].split('+')[0])
        if 'primary' in line.decode('utf-8'):
            monitor_primary = line.decode('utf-8').split(' ')[0] + ' ' + line.decode('utf-8').split(' ')[3].split('+')[0]

    ## Hack for Wayland
    try:
        monitor_primary
    except NameError:
        monitor_primary = monitors_list[0]
    else:
        pass

    return monitors_list, monitor_primary 
开发者ID:yancharkin,项目名称:games_nebula,代码行数:58,代码来源:monitors.py

示例14: __init__

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def __init__(self):
        Gtk.Window.__init__(self)
        self.set_default_size(600, 600)
        self.connect('destroy', lambda win: Gtk.main_quit())

        self.set_title('GtkListStore demo')
        self.set_border_width(8)

        vbox = Gtk.VBox(False, 8)
        self.add(vbox)

        label = Gtk.Label('Double click a row to plot the data')

        vbox.pack_start(label, False, False, 0)

        sw = Gtk.ScrolledWindow()
        sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        sw.set_policy(Gtk.PolicyType.NEVER,
                      Gtk.PolicyType.AUTOMATIC)
        vbox.pack_start(sw, True, True, 0)

        model = self.create_model()

        self.treeview = Gtk.TreeView(model)
        self.treeview.set_rules_hint(True)

        # matplotlib stuff
        fig = Figure(figsize=(6, 4))

        self.canvas = FigureCanvas(fig)  # a Gtk.DrawingArea
        vbox.pack_start(self.canvas, True, True, 0)
        ax = fig.add_subplot(111)
        self.line, = ax.plot(self.data[0, :], 'go')  # plot the first row

        self.treeview.connect('row-activated', self.plot_row)
        sw.add(self.treeview)

        self.add_columns()

        self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK |
                        Gdk.EventMask.KEY_PRESS_MASK |
                        Gdk.EventMask.KEY_RELEASE_MASK) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:44,代码来源:gtk_spreadsheet_sgskip.py

示例15: do_startup

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import Gdk [as 别名]
def do_startup(self):
        Gtk.Application.do_startup(self)

        self.start_time = datetime.now()
        log.info("green<Starting>")

        style_provider = Gtk.CssProvider()
        style_provider.load_from_path(os.path.join(Paths.STYLEDIR, "style.css"))

        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(), style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )

        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(Paths.UIDIR, 'menu.ui'))

        self.app_menu = self.builder.get_object('appmenu')
        self.set_app_menu(self.app_menu)

        actions = ['open','new_window', 'about', 'quit', 'launch_hal_meter', 
                'launch_hal_scope', 'launch_hal_configuration', 'launch_classicladder', 
                'launch_status']

        for action in actions:
            self.add_simple_action(action)

        toggle_actions = ['estop', 'power','edit_layout', 'dark_theme']
        for action in toggle_actions:
            self.add_toggle_action(action)

        status.on_changed('stat.task_state', self.on_task_state_changed)
        status.on_changed('stat.interp_state', self.on_interp_state_changed)

        # Show any Startup Notifications given in INI
        startup_notification = ini_info.get_startup_notification()
        if startup_notification:
            notifications.show_info(startup_notification, timeout=0)

        startup_warning = ini_info.get_startup_warning()
        if startup_warning:
            notifications.show_warning(startup_warning, timeout=0)

        log_time('app startup done') 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:46,代码来源:main.py


注:本文中的gi.repository.Gdk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。