wxPython dirpickerctrl文本框出现在其自己的浏览按钮上

时间:2018-11-07 15:27:11

标签: user-interface wxpython

我的wxPython dirPickerCtrl文本框显示在其浏览按钮的上方。

我的代码是:

class chooseFolder(wx.DirPickerCtrl):
    def __init__(self, *args, **kwargs):
        wx.DirPickerCtrl.__init__(self, *args, **kwargs)

dataFolder = chooseFolder(self, -1, message= 'Choose Folder', pos = (55,24), 
                          style= wx.DIRP_DEFAULT_STYLE,
                          size = (250, 25))

我尝试在该面板中应用不同的大小调整器,以查看是否可以解决该问题,但无济于事。

我正在使用wx版本4.0.3

编辑:下面是演示我遇到的问题的最小代码示例,如第二张图片所示。

import wx
import os

class ButtonFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None)
        self.panel = wx.Panel(self, -1)

        chooseFolder(parent=self,
                     pos = (10,100),
                     style= wx.DIRP_DEFAULT_STYLE,
                     size = (250, 30))

        self.Centre()
        self.Show()

class chooseFolder(wx.DirPickerCtrl):
    def __init__(self, *args, **kwargs):
        wx.DirPickerCtrl.__init__(self, *args, **kwargs)

if __name__ == "__main__":

    app = wx.App()
    ButtonFrame()
    app.MainLoop()

picture of text box on top of button

EDIT: Picture of output from minimal code example

2 个答案:

答案 0 :(得分:1)

根据提供的代码示例进行编辑:
我无法在Windows上进行测试,但看起来好像是个错误(在Linux上有效)。
如果您不对DirPickerCtrl进行子类化,而是直接使用它,会得到相同的结果吗?像这样:

import wx

class ButtonFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None)
        self.panel = wx.Panel(self, -1)

        chooseFolder = wx.DirPickerCtrl(self.panel, -1, pos = (10,100), path = "",
            style= wx.DIRP_DEFAULT_STYLE,
            size = (250, 30))

#        chooseFolder(parent=self,
#            id = -1,
#            pos = (10,100),
#            path = "/home",
#            style= wx.DIRP_DEFAULT_STYLE)#,
#            #size = (250, 30))

        self.Centre()
        self.Show()

#class chooseFolder(wx.DirPickerCtrl):
#    def __init__(self, *args, **kwargs):
#        wx.DirPickerCtrl.__init__(self, *args, **kwargs)

if __name__ == "__main__":

    app = wx.App()
    ButtonFrame()
    app.MainLoop()

您提到您曾尝试将大小调整器应用于面板,但问题是根本没有引用面板。
尝试使用下面的代码,看看是否有帮助。
为简单起见,它仅依赖于固定位置(无大小调整器)。

import wx
import os

class ButtonFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,None)
        self.panel = wx.Panel(self, -1)
        self.BtnPressHere = wx.Button(self.panel, -1, "Press Here", pos=(10,10))
        self.BtnPressHere.Bind(wx.EVT_BUTTON, self.OnPress)
        self.Bind(wx.EVT_DIRPICKER_CHANGED, self.DirChange)
        self.Centre()
        self.Show()
        print("Current Dir: ",os.getcwd())

    def OnPress(self,event):
        dataFolder = chooseFolder(parent=self,
             id=-1,
             path='/home',
             message='Choose Folder',
             pos = (10,100),
             style= wx.DIRP_DEFAULT_STYLE|wx.DIRP_CHANGE_DIR,
             size = (250, 30))

    def DirChange(self,event):
        print("Dir changed to: ", event.GetPath())
        print("Checking Current Dir: ",os.getcwd())

class chooseFolder(wx.DirPickerCtrl):
    def __init__(self, *args, **kwargs):
        wx.DirPickerCtrl.__init__(self, *args, **kwargs)

if __name__ == "__main__":

    app = wx.App()
    ButtonFrame()
    app.MainLoop()

enter image description here

答案 1 :(得分:0)

我认为问题出在给构造函数的@Component public class HealthCheck1 extends AbstractHealthIndicator { @Override protected void doHealthCheck(Health.Builder builder) throws InterruptedException { Thread.sleep(5000); // actually make a service call builder.up(); } } @Component public class HealthCheck2 extends AbstractHealthIndicator { @Override protected void doHealthCheck(Health.Builder builder) throws InterruptedException { Thread.sleep(5000); // actually make a service call builder.up(); } } 上。尝试将高度($ time http localhost:8080/actuator/health HTTP/1.1 200 Connection: keep-alive Content-Type: application/vnd.spring-boot.actuator.v3+json Date: Fri, 03 Jan 2020 14:54:31 GMT Keep-Alive: timeout=60 Transfer-Encoding: chunked { "components": { "diskSpace": { "details": { "free": 398020632576, "threshold": 10485760, "total": 499963174912 }, "status": "UP" }, "healthCheck1": { "status": "UP" }, "healthCheck2": { "status": "UP" }, "ping": { "status": "UP" } }, "status": "UP" } real 0m10.359s user 0m0.242s sys 0m0.036s 的第二个参数)设置为size