Pyforms窗体总是最大化

2024-05-19 02:11:29 发布

您现在位置:Python中文网/ 问答频道 /正文

当我运行脚本时,主窗体会弹出最大化(即占用屏幕上的所有空间)。我试图使用CSS文件设置表单的高度和宽度,但是没有成功。我在别的地方没看到过。在

我的代码是:

import sys
import pyforms
from pyforms import BaseWidget
from pyforms.Controls import ControlText
from pyforms.Controls import ControlButton
from pyforms.Controls import ControlFile
class ImportIntoFile(BaseWidget):

def __init__(self):
    super(ImportIntoFile,self).__init__('HTCondor & EnergyPlus')

    self._Input     = ControlFile('Input')
    self._Output    = ControlFile('Output')
    self._Import    = ControlButton('Import')
    self._Close     = ControlButton('Close')

    self._formset = ['',('  ','_Input','  '),('  ','_Output','  '),('','_Close','','_Import',''),'']

    self._Import.value = self.__ImportAction
    self._Close.value = self.__CloseAction

def __ImportAction(self):
    OutputFile = open(self._Output.value,'a')       
    InputFile = open(self._Input.value,'r')

    OutputFile.close
    InputFile.close

def __CloseAction(self):
    sys.exit()

if __name__ == "__main__":   pyforms.startApp( ImportIntoFile )`

Tags: fromimportselfcloseinputoutputvaluedef
3条回答

我也有同样的问题。Pyforms使用Qt、so some of these modules will be familiarthis css will modify them。在

我用过:

QMainWindow{
    max-width:500px;
    max-height:500px;
}

要成功设置主窗口的大小,但以后不能再增加大小,所以如果您只需要一个固定大小的窗口,它就可以工作了。在

我也找不到好的解决办法。为了避免默认情况下最大化的临时解决方法,我所做的是修改C:\Python27\Lib\site packages\pyforms\gui\standaloneManager.py. 在

if geometry is not None:
    w.show()
    w.setGeometry(*geometry)
else:
    w.showMaximized()

^{pr2}$

您可以将窗口几何体传递给pyforms.start_app()调用。所以下面的代码应该可以工作。在

if __name__ == "__main__":
    pyforms.start_app( ImportIntoFile, geometry=(200, 200, 400, 400) )

相关问题 更多 >

    热门问题