• <legend id='vGJJp'><style id='vGJJp'><dir id='vGJJp'><q id='vGJJp'></q></dir></style></legend>

    <i id='vGJJp'><tr id='vGJJp'><dt id='vGJJp'><q id='vGJJp'><span id='vGJJp'><b id='vGJJp'><form id='vGJJp'><ins id='vGJJp'></ins><ul id='vGJJp'></ul><sub id='vGJJp'></sub></form><legend id='vGJJp'></legend><bdo id='vGJJp'><pre id='vGJJp'><center id='vGJJp'></center></pre></bdo></b><th id='vGJJp'></th></span></q></dt></tr></i><div id='vGJJp'><tfoot id='vGJJp'></tfoot><dl id='vGJJp'><fieldset id='vGJJp'></fieldset></dl></div>
    <tfoot id='vGJJp'></tfoot>

    <small id='vGJJp'></small><noframes id='vGJJp'>

        <bdo id='vGJJp'></bdo><ul id='vGJJp'></ul>
      1. Kivy 窗口隐藏/显示

        时间:2023-10-09

        <small id='iyfNm'></small><noframes id='iyfNm'>

        1. <legend id='iyfNm'><style id='iyfNm'><dir id='iyfNm'><q id='iyfNm'></q></dir></style></legend>
          <tfoot id='iyfNm'></tfoot>

              <tbody id='iyfNm'></tbody>
              <bdo id='iyfNm'></bdo><ul id='iyfNm'></ul>

                  <i id='iyfNm'><tr id='iyfNm'><dt id='iyfNm'><q id='iyfNm'><span id='iyfNm'><b id='iyfNm'><form id='iyfNm'><ins id='iyfNm'></ins><ul id='iyfNm'></ul><sub id='iyfNm'></sub></form><legend id='iyfNm'></legend><bdo id='iyfNm'><pre id='iyfNm'><center id='iyfNm'></center></pre></bdo></b><th id='iyfNm'></th></span></q></dt></tr></i><div id='iyfNm'><tfoot id='iyfNm'></tfoot><dl id='iyfNm'><fieldset id='iyfNm'></fieldset></dl></div>
                  本文介绍了Kivy 窗口隐藏/显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我是 python 编程和技巧的新手,学习让我创建一个项目.这就是我想要做的.我想创建一个在系统托盘中运行的程序并启动一个在后台加载的程序.在后台加载,这样我可以减少 Kivy 的启动时间.在这里和谷歌上搜索后,我找不到答案.

                  I'm a newby with python programming and tought, to learn let me create a project. Here is what i'm trying to do. I want to create a program that runs in system tray and fire's a program that is loaded in the background. Loaded in the background so I can reduce the start time of Kivy. After searching here and on google, i could not find the answer.

                  我有两个文件

                  from kivy.app import App
                  from kivy.uix.button import Button
                  from kivy.uix.label import Label
                  from kivy.uix.boxlayout import BoxLayout
                  from kivy.config import Config
                  from kivy.uix.screenmanager import ScreenManager, Screen
                  from kivy.core.window import Window
                  from kivy.config import Config
                  # 
                  
                  import kivy
                  from kivy.app import App
                  from kivy.uix.button import Button
                  from kivy.core.window import Window
                  
                  Config.set('graphics', 'window_state', 'hidden')
                  
                  class MyApp(App):
                      visible = False
                  
                      def build(self):
                          Window.bordeless = 'True'
                          return Button(text='Hello World')
                  
                      def on_start(self):
                          if self.visible:
                              self.root_window.hide()
                          self.visible = not self.visible
                          # self.root.focus = True
                  
                      def do_show(self):
                          rootWindow = self.root_window
                          rootWindow.show()
                          print(self.root_window.focus)
                  
                  if __name__ in ('__main__'):
                      ma = MyApp().run()
                  

                  import wx
                  import someKivyThigy
                  from kivy.app import App
                  from someKivyThigy import MyApp
                  from buttonThing import MyDebugApp
                  from kivy.core.window import Window
                  
                  TRAY_TOOLTIP = 'System Tray Demo'
                  TRAY_ICON = 'icon.png'
                  
                  testVar = MyApp
                  
                  def create_menu_item(menu, label, func):
                      item = wx.MenuItem(menu, -1, label)
                      menu.Bind(wx.EVT_MENU, func, id=item.GetId())
                      menu.AppendItem(item)
                      return item
                  
                  
                  class TaskBarIcon(wx.TaskBarIcon):
                      def __init__(self):
                          super(TaskBarIcon, self).__init__()
                          self.set_icon(TRAY_ICON)
                          self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
                  
                      def CreatePopupMenu(self):
                          menu = wx.Menu()
                          create_menu_item(menu, 'Say Hello', self.on_hello)
                          menu.AppendSeparator()
                          create_menu_item(menu, 'Exit', self.on_exit)
                          return menu
                  
                      def set_icon(self, path):
                          icon = wx.IconFromBitmap(wx.Bitmap(path))
                          self.SetIcon(icon, TRAY_TOOLTIP)
                  
                      def on_left_down(self, event):
                          print 'Tray icon was left-clicked.'
                          MyApp().do_show()
                  
                  
                      def on_hello(self, event):
                          print 'Hello, world!'
                  
                      def on_exit(self, event):
                          wx.CallAfter(self.Destroy)
                  
                  
                  def main():
                      app = wx.PySimpleApp()
                      TaskBarIcon()
                      testVar = MyApp().run()
                      app.MainLoop()
                  
                  if __name__ == '__main__':
                      main()
                  

                  当我左键单击系统托盘图标时,我收到错误消息:AttributeError: 'NoneType' object has no attribute 'show'".我做错了什么?

                  When i left click the system tray icon, i get the error: "AttributeError: 'NoneType' object has no attribute 'show'". What am I doing wrong?

                  推荐答案

                  Kivy 是专门为Android 平台制作的,但这并不意味着它不能用于桌面应用程序开发.但请记住,窗口管理器将 SLD2 提供程序保持为支持状态,因此此提供程序支持隐藏窗口但无法恢复它.

                  Kivy was made specially for Android Platform but it does not mean that it can't be used for desktop application development. But keep in mind that Window manager works with keeping SLD2 provider as backened so, this provider supports hide the window but cannot restore it.

                  对于隐藏窗口,您可以使用:Window.hide() after importing Window from kivy.core.window

                  For hiding window you can use : Window.hide() after importing Window from kivy.core.window

                  对于恢复,您可以使用:Window.restore() 或 Window.show()

                  And for restoring you can use: Window.restore() or Window.show()

                  这篇关于Kivy 窗口隐藏/显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 Kivy 中创建动态绘制的线 下一篇:如何在 Kivy python 中最大化滚动条?

                  相关文章

                  最新文章

                    <tfoot id='klBPv'></tfoot>
                    <legend id='klBPv'><style id='klBPv'><dir id='klBPv'><q id='klBPv'></q></dir></style></legend>

                    <small id='klBPv'></small><noframes id='klBPv'>

                  1. <i id='klBPv'><tr id='klBPv'><dt id='klBPv'><q id='klBPv'><span id='klBPv'><b id='klBPv'><form id='klBPv'><ins id='klBPv'></ins><ul id='klBPv'></ul><sub id='klBPv'></sub></form><legend id='klBPv'></legend><bdo id='klBPv'><pre id='klBPv'><center id='klBPv'></center></pre></bdo></b><th id='klBPv'></th></span></q></dt></tr></i><div id='klBPv'><tfoot id='klBPv'></tfoot><dl id='klBPv'><fieldset id='klBPv'></fieldset></dl></div>

                        <bdo id='klBPv'></bdo><ul id='klBPv'></ul>