- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试为 Gedit 3 编写一个使用 GObject 自省(introspection)的小插件。下面显示的代码的相关部分旨在建立一个环境,然后我可以在该环境中适应按钮回调中的函数。但是,按钮的加速器不起作用。
我正在使用教程 here和 GTK 3 的 python 文档 here .还有其他您知道的链接吗?
from gi.repository import Gtk, Gedit, GObject
ui_string = """<ui>
<toolbar name="ToolBar">
<separator />
<toolitem name="Test" action="Test" />
</toolbar>
</ui>
"""
class test:
def __init__(self, plugin, window):
self.window = window
self.plugin = plugin
self.ui_id = None
manager = self.window.get_ui_manager()
action_group = Gtk.ActionGroup("TestPluginactions")
action_test_button = Gtk.Action(name="Test",
label="Test",
tooltip="Test",
stock_id=Gtk.STOCK_EXECUTE)
action_test_button.connect("activate", self.testcallback)
action_group.add_action_with_accel(action_test_button, "<Ctrl>l")
manager.insert_action_group(action_group, -1)
self.ui_id = manager.add_ui_from_string(ui_string)
manager.ensure_update()
def deactivate(self):
manager = self.window.get_ui_manager()
manager.remove_ui(self.ui_id)
self.ui_id = None
self.window = None
self.plugin = None
def testcallback(self,unused):
dialog1 = Gtk.MessageDialog(self.window,Gtk.DialogFlags.DESTROY_WITH_PARENT,
Gtk.MessageType.ERROR,Gtk.ButtonsType.OK,"TEST")
dialog1.run()
dialog1.destroy()
class WindowActivatable(GObject.Object, Gedit.WindowActivatable):
window = GObject.property(type=Gedit.Window)
def __init__(self):
GObject.Object.__init__(self)
self.instances = {}
def do_activate(self):
self.instances[self.window] = test(self, self.window)
def do_deactivate(self):
if self.window in self.instances:
self.instances[self.window].deactivate()
最佳答案
知道 GTK 3 有一些错误,不允许以上面显示的方式将快捷方式分配给工具项。然而,菜单项工作正常。所以下面的代码更好。
from gi.repository import Gtk, Gedit, GObject
ui_string = """<ui>
<toolbar name="ToolBar">
<separator />
<toolitem name="Test" action="Test" />
</toolbar>
<menubar name="MenuBar">
<menu name="ToolsMenu" action="Tools">
<placeholder name="ToolsOps_2">
<menuitem name="test1" action="test1"/>
</placeholder>
</menu>
</menubar>
</ui>
"""
class test:
def __init__(self, plugin, window):
self.window = window
self.plugin = plugin
self.ui_id = None
manager = self.window.get_ui_manager()
action_group = Gtk.ActionGroup("TestPluginactions")
action_test_button = Gtk.Action(name="Test",
label="Test",
tooltip="Test",
stock_id=Gtk.STOCK_EXECUTE)
action_test = Gtk.Action(name="test1",
label="Test",
tooltip="Test",
stock_id=Gtk.STOCK_EXECUTE)
action_test_button.connect("activate", self.testcallback)
action_test.connect("activate", self.testcallback)
action_group.add_action(action_test_button)
action_group.add_action_with_accel(action_test, "<Ctrl>l")
manager.insert_action_group(action_group, -1)
self.ui_id = manager.add_ui_from_string(ui_string)
manager.ensure_update()
def deactivate(self):
manager = self.window.get_ui_manager()
manager.remove_ui(self.ui_id)
self.ui_id = None
self.window = None
self.plugin = None
def testcallback(self,unused):
dialog1 = Gtk.MessageDialog(self.window,Gtk.DialogFlags.DESTROY_WITH_PARENT,
Gtk.MessageType.ERROR,Gtk.ButtonsType.OK,"TEST")
dialog1.run()
dialog1.destroy()
class WindowActivatable(GObject.Object, Gedit.WindowActivatable):
window = GObject.property(type=Gedit.Window)
def __init__(self):
GObject.Object.__init__(self)
self.instances = {}
def do_activate(self):
self.instances[self.window] = test(self, self.window)
def do_deactivate(self):
if self.window in self.instances:
self.instances[self.window].deactivate()
关于python - Accel 在 gedit 3 插件中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22594173/
我正在尝试添加身份验证以仅允许有效用户从 nginx 下载静态文件。 这是我的 Nginx 配置: location ^~ /download-logs { internal; ali
这是我在 nginx 上的“内部”设置: location /issues/ { root /home/some_user/some_project/; internal; } 当我注
我使用 nginx x-accel-redirect 作为外部资源的身份验证前端。 在我的 python 代码中,我将执行以下操作: /获取资源/ def view(self, req, resp):
我使用 nginx x-accel-redirect 作为外部资源的身份验证前端。 在我的 python 代码中,我将执行以下操作: /获取资源/ def view(self, req, resp):
据我了解,这 3 个字段的单位是弧度/秒。它们非常适合跟踪 3D 运动,但不适合单独使用(无需校准)。 所以想法似乎是使用 Accel+Magnetic 生成矩阵,但由于这不准确,您使用陀螺仪数据对数
我正在尝试为 Gedit 3 编写一个使用 GObject 自省(introspection)的小插件。下面显示的代码的相关部分旨在建立一个环境,然后我可以在该环境中适应按钮回调中的函数。但是,按钮的
到目前为止,我一直在摸索着保护 Django 的媒体文件,但没有成功!我只是想让它只有管理员用户才能访问媒体文件夹。这是我的 Nginx 文件。 server { listen 80;
我正在尝试从非公共(public)目录提供文件,但一点乐趣都没有。 server { listen 80; listen [::]:80; root /websites/testing.com; in
我将我的网站分为公共(public)区域和私有(private)区域。所有静态文件都将由 nginx 提供。 Nodejs 仅检查凭据并在成功时设置 X-Accel-Redirect-Header。问
要对 passenger 使用 Nginx 的 X-Accel-Redirect 功能,显然您使用 passenger_set_header,如果映射到另一个位置,则使用 passenger_set_
我在Nginx中使用X-Accel-Redirect在Rails中提供受限下载。为了验证我在客户端应用中的下载,我正在尝试将非标准HTTP header Content-MD5中的校验和发送到X-Ac
我想将 Nginx X-Accel 与 Symfony 一起使用,目前我已经有了这段代码。 $request->headers->set('X-Sendfile-Type', 'X-Accel
These are the docs for X-Accel-Limit-Rate : Sets the rate limit for this single request. Off means u
我正在开发一个 Web 应用程序,X-Accel-Redirect header 只能在没有扩展名的文件中正常工作。出于某种原因,如果我向文件名添加扩展名,X-Accel-Redirect 将不起作用
我正在尝试使用G++ 9.3.0编译以下简单的OpenMP GPU卸载程序: #include int main(){ const int N=1000; int d[N]; for(a
我正在尝试为我在 Ubuntu 上开发的程序连接一些键绑定(bind)。键绑定(bind)本身是有效的,但是 wxPython 菜单似乎无法将 Numpad 键映射到加速表,因此热键组合出现在菜单项旁
您好,我希望用户能够从我配置了 nginx PHP 的服务器 (Windows) 下载 PDF 文件。这是我的 nginx.conf(服务器 block ) http { include
我正在尝试在 node.js 支持的 nginx 上设置授权文件访问。出于某种原因,所有示例都不适合我。我正在尝试从 /data/private/files 服务器文件 我的 nginx 配置: ..
阅读this article在 nginx 网站上,我有兴趣使用 X-Accel-重定向 Apache 或 Lighttpd 用户可能使用 的方式X-Sendfile 头来帮助处理大文件。 最tuto
我们正在迁移到 kubernetes,我们对它是全新的。 在我们当前的单一服务设置中,我们有:Nginx -> Web 应用程序。通过这种方式,我们可以在 Web 应用程序中通过身份验证来保护一些静态
我是一名优秀的程序员,十分优秀!