問題描述
我正在嘗試從完全不同的 GUI 打開一個 GUI.我正在桌面上開發,并且窗口的大小彼此不同.我查看了屏幕管理器,但感覺好像有更簡單的方法可以做到這一點.
I am trying to open one GUI from a completely different GUI. I am developing on a desktop and the windows have different sizes from each other. I looked at screen manager but I feel as if there is an easier way to do this.
提前致謝!
推薦答案
有可能,但有點不方便.問題是 kivy 每個應用程序僅支持一個窗口,因此您需要以某種方式解決它.我個人只是在一個窗口中使用多個 *Layouts(它們是具有不同功能的不同 GUI),并根據需要顯示和隱藏它們.顯然這種方法有其局限性,eg它不支持多顯示器,但它很簡單.
It's possible, but kinda inconvenient. The issue is that kivy supports only one window per app, so you need to work around it somehow. I personally just use multiple *Layouts (which are different GUIs with different functions) in a single window, showing and hiding them as necessary. Obviously this approach has its restrictions, eg it doesn't support multiple monitors, but it's as simple as it gets.
然后有一個問題 在這里,人們為每個窗口生成單獨的 kivy 應用程序,從而獲得可以相對拖動和調整大小的窗口.它需要一些子進程的擺弄和應用程序之間的通信,但這種方法更強大.
Then there is a question here on SO where people spawn separate kivy apps for every window, thus getting windows that can be dragged and resized relatively. It requires some fiddling with subprocesses and communicating between apps, but this method is more powerful.
據我所知,ScreenManager 對您沒有幫助:它只允許為同一個窗口定義多個小部件樹并在它們之間動態切換.這是觸摸屏上的正常用例,但在桌面上幾乎沒有意義.老實說,這對于 kivy 中的很多事情都是正確的.如果你以后不打算轉向手機,Tkinter 或 PyQT 可能是比 kivy 更好的選擇.
ScreenManager, as I understand, doesn't help you: it allows just to define multiple widget trees for the same window and switch between them on the fly. It's a normal use case on touchscreens, but makes pretty little sense on desktop. Which is true for quite a few things in kivy, to be honest. If you don't plan to move to mobiles later, Tkinter or PyQT may be a better choice than kivy.
這篇關于如何在 Kivy 中擁有多個窗口?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!