Python 当我尝试运行pyqt5应用程序时,请打开窗口';大小不一
我使用QT designer设计了一个应用程序ui,并将其转换为.py文件,但当我尝试使用python运行应用程序时,窗口的大小不会显示为QT designer中的大小,并且会剪切一些文本 我已经更改了python版本,但不起作用 我也尝试了升华而不是pycharm,并面临同样的问题。我在另一台计算机上尝试了我的代码,并且工作正常。任何小费 q64686336_main.pyPython 当我尝试运行pyqt5应用程序时,请打开窗口';大小不一,python,python-3.x,pyqt5,qt-designer,Python,Python 3.x,Pyqt5,Qt Designer,我使用QT designer设计了一个应用程序ui,并将其转换为.py文件,但当我尝试使用python运行应用程序时,窗口的大小不会显示为QT designer中的大小,并且会剪切一些文本 我已经更改了python版本,但不起作用 我也尝试了升华而不是pycharm,并面临同样的问题。我在另一台计算机上尝试了我的代码,并且工作正常。任何小费 q64686336_main.py from PyQt5.QtGui import * from PyQt5.QtCore import * from Py
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import sys
from PyQt5.uic import loadUiType
import os
from os import path
ui, _ = loadUiType(path.join(path.dirname(__file__),"q64686336.ui"))
class MainApp(QMainWindow, ui):
def __init__(self , parent=None):
super(MainApp , self).__init__(parent)
QMainWindow.__init__(self)
self.setupUi(self)
def main():
app = QApplication(sys.argv)
window = MainApp()
window.show()
app.exec_()
if __name__ == '__main__':
main()
q64686336.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>496</width>
<height>246</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="styleSheet">
<string notr="true">
QWidget {
background-color:rgb(0, 0, 0);
color: rgb(240, 240, 240);
border-color: rgb(58, 58, 58);
}
QPlainTextEdit {
background-color:rgb(0, 0, 0);
color: rgb(200, 200, 200);
selection-background-color: rgb(255, 0, 0);
selection-color: rgb(0, 0, 0);
}
QTabWidget::pane {
border-top: 1px solid #000000;
}
QTabBar::tab {
background-color:rgb(0, 0, 0);
border-style: outset;
border-width: 1px;
border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
border-bottom-color: rgb(58, 58, 58);
border-bottom-width: 1px;
border-top-width: 0px;
border-style: solid;
color: rgb(255, 0, 0);
padding: 4px;
}
QTabBar::tab:selected, QTabBar::tab:hover {
color: rgb(255, 255, 255);
background-color:rgb(0, 0, 0);
border-color:rgb(42, 42, 42);
margin-left: 0px;
margin-right: 0px;
border-bottom-right-radius:4px;
border-bottom-left-radius:4px;
}
QTabBar::tab:last:selected {
background-color:rgb(0, 0, 0);
border-color:rgb(42, 42, 42);
margin-left: 0px;
margin-right: 0px;
border-bottom-right-radius:4px;
border-bottom-left-radius:4px;
}
QTabBar::tab:!selected {
margin-bottom: 4px;
border-bottom-right-radius:4px;
border-bottom-left-radius:4px;
}
QPushButton{
border-style: outset;
border-width: 2px;
border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
border-bottom-color: rgb(58, 58, 58);
border-bottom-width: 1px;
border-style: solid;
color: rgb(255, 255, 255);
padding: 6px;
background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(77, 77, 77, 255), stop:1 rgba(97, 97, 97, 255));
}
QPushButton:hover{
border-style: outset;
border-width: 2px;
border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(180, 180, 180, 255), stop:1 rgba(110, 110, 110, 255));
border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(180, 180, 180, 255), stop:1 rgba(110, 110, 110, 255));
border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(180, 180, 180, 255), stop:1 rgba(110, 110, 110, 255));
border-bottom-color: rgb(115, 115, 115);
border-bottom-width: 1px;
border-style: solid;
color: rgb(255, 255, 255);
padding: 6px;
background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(107, 107, 107, 255), stop:1 rgba(157, 157, 157, 255));
}
QPushButton:pressed{
border-style: outset;
border-width: 2px;
border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(62, 62, 62, 255), stop:1 rgba(22, 22, 22, 255));
border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
border-bottom-color: rgb(58, 58, 58);
border-bottom-width: 1px;
border-style: solid;
color: rgb(255, 255, 255);
padding: 6px;
background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(77, 77, 77, 255), stop:1 rgba(97, 97, 97, 255));
}
QPushButton:disabled{
border-style: outset;
border-width: 2px;
border-top-color: qlineargradient(spread:pad, x1:0.5, y1:0.6, x2:0.5, y2:0.4, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
border-right-color: qlineargradient(spread:pad, x1:0.4, y1:0.5, x2:0.6, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
border-left-color: qlineargradient(spread:pad, x1:0.6, y1:0.5, x2:0.4, y2:0.5, stop:0 rgba(115, 115, 115, 255), stop:1 rgba(62, 62, 62, 255));
border-bottom-color: rgb(58, 58, 58);
border-bottom-width: 1px;
border-style: solid;
color: rgb(0, 0, 0);
padding: 6px;
background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(57, 57, 57, 255), stop:1 rgba(77, 77, 77, 255));
}
QLineEdit {
border-width: 1px; border-radius: 4px;
border-color: rgb(58, 58, 58);
border-style: inset;
padding: 0 8px;
color: rgb(255, 255, 255);
background:rgb(101, 101, 101);
selection-background-color: rgb(187, 187, 187);
selection-color: rgb(60, 63, 65);
}
QProgressBar {
text-align: center;
color: rgb(255, 255, 255);
border-width: 1px;
border-radius: 10px;
border-color: rgb(58, 58, 58);
border-style: inset;
}
QProgressBar::chunk {
background-color: qlineargradient(spread:pad, x1:0.5, y1:0.7, x2:0.5, y2:0.3, stop:0 rgb(255 , 0 , 0), stop:1 rgb(255 , 0 , 0));
border-radius: 10px;
}
QMenuBar {
background:rgb(0, 0, 0);
color: rgb(255, 0, 0);
}
QMenuBar::item {
spacing: 3px;
padding: 1px 4px;
background: transparent;
}
QMenuBar::item:selected {
background:rgb(115, 115, 115);
}
QMenu {
border-width: 2px;
border-radius: 10px;
border-color: rgb(255, 0, 0);
border-style: outset;
}
QMenu::item {
spacing: 3px;
padding: 3px 15px;
}
QMenu::item:selected {
spacing: 3px;
padding: 3px 15px;
background:rgb(115, 115, 115);
color:rgb(255, 255, 255);
border-width: 1px;
border-radius: 10px;
border-color: rgb(58, 58, 58);
border-style: inset;
}</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>481</width>
<height>221</height>
</rect>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>47</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>URL </string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>63</y>
<width>47</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Location</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>340</x>
<y>60</y>
<width>71</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>90</x>
<y>20</y>
<width>321</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
<x>103</x>
<y>100</y>
<width>291</width>
<height>25</height>
</rect>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_2">
<property name="geometry">
<rect>
<x>90</x>
<y>60</y>
<width>251</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>146</x>
<y>140</y>
<width>211</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Download</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>20</x>
<y>63</y>
<width>47</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Location</string>
</property>
</widget>
<widget class="QProgressBar" name="progressBar_2">
<property name="geometry">
<rect>
<x>103</x>
<y>100</y>
<width>291</width>
<height>25</height>
</rect>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>47</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>URL </string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_3">
<property name="geometry">
<rect>
<x>146</x>
<y>140</y>
<width>211</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Download</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_3">
<property name="geometry">
<rect>
<x>90</x>
<y>20</y>
<width>321</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_4">
<property name="geometry">
<rect>
<x>90</x>
<y>60</y>
<width>251</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton_4">
<property name="geometry">
<rect>
<x>340</x>
<y>60</y>
<width>71</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</widget>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>496</width>
<height>19</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
主窗口
0
0
496
246
主窗口
QWidget{
背景色:rgb(0,0,0);
颜色:rgb(240、240、240);
边框颜色:rgb(58,58,58);
}
QPlainTextEdit{
背景色:rgb(0,0,0);
颜色:rgb(200200200200);
选择背景色:rgb(255,0,0);
选择颜色:rgb(0,0,0);
}
QTabWidget::窗格{
边框顶部:1px实心#000000;
}
QTabBar::tab{
背景色:rgb(0,0,0);
边界样式:开始;
边框宽度:1px;
右边框颜色:QlineArgent(排列:焊盘,x1:0.4,y1:0.5,x2:0.6,y2:0.5,停止:0 rgba(115,115,115,255),停止:1 rgba(62,62,62255));
左边框颜色:QlineArgent(排列:焊盘,x1:0.6,y1:0.5,x2:0.4,y2:0.5,停止:0 rgba(115,115,115,255),停止:1 rgba(62,62,62,255));
边框底色:rgb(58,58,58);
边框底宽:1px;
边框顶部宽度:0px;
边框样式:实心;
颜色:rgb(255,0,0);
填充:4px;
}
QTabBar::tab:选中,QTabBar::tab:悬停{
颜色:rgb(255、255、255);
背景色:rgb(0,0,0);
边框颜色:rgb(42,42,42);
左边距:0px;
右边距:0px;
边框右下半径:4px;
边框左下半径:4px;
}
QTabBar::选项卡:最后:已选定{
背景色:rgb(0,0,0);
边框颜色:rgb(42,42,42);
左边距:0px;
右边距:0px;
边框右下半径:4px;
边框左下半径:4px;
}
QTabBar::tab:!精选{
利润底部:4倍;
边框右下半径:4px;
边框左下半径:4px;
}
QPushButton{
边界样式:开始;
边框宽度:2倍;
边框顶部颜色:QlineArgent(排列:焊盘,x1:0.5,y1:0.6,x2:0.5,y2:0.4,停止:0 rgba(115,115,115,255),停止:1 rgba(62,62,62,255));
右边框颜色:QlineArgent(排列:焊盘,x1:0.4,y1:0.5,x2:0.6,y2:0.5,停止:0 rgba(115,115,115,255),停止:1 rgba(62,62,62255));
左边框颜色:QlineArgent(排列:焊盘,x1:0.6,y1:0.5,x2:0.4,y2:0.5,停止:0 rgba(115,115,115,255),停止:1 rgba(62,62,62,255));
边框底色:rgb(58,58,58);
边框底宽:1px;
边框样式:实心;
颜色:rgb(255、255、255);
填充:6px;
背景色:QlineArgent(排列:pad,x1:0.5,y1:1,x2:0.5,y2:0,停止:0 rgba(77,77,77,255),停止:1 rgba(97,97,97,255));
}
QPushButton:悬停{
边界样式:开始;
边框宽度:2倍;
边框顶部颜色:QlineArgent(排列:焊盘,x1:0.5,y1:0.6,x2:0.5,y2:0.4,停止:0 rgba(180,180,180,255),停止:1 rgba(110,110,110,255));
右边框颜色:QlineArgent(排列:pad,x1:0.4,y1:0.5,x2:0.6,y2:0.5,停止:0 rgba(180,180,180,255),停止:1 rgba(110,110,110,255));
左边框颜色:QlineArgent(排列:焊盘,x1:0.6,y1:0.5,x2:0.4,y2:0.5,停止:0 rgba(180,180,180,255),停止:1 rgba(110,110,110,255));
边框底色:rgb(115、115、115);
边框底宽:1px;
边框样式:实心;
颜色:rgb(255、255、255);
填充:6px;
背景色:QlineArgent(排列:pad,x1:0.5,y1:1,x2:0.5,y2:0,停止:0 rgba(107,107,107,255),停止:1 rgba(157,157,157,255));
}
QPUSH按钮:按下{
边界样式:开始;
边框宽度:2倍;
边框顶部颜色:QlineArgent(排列:焊盘,x1:0.5,y1:0.6,x2:0.5,y2:0.4,停止:0 rgba(62,62,62,255),停止:1 rgba(22,22,225));
右边框颜色:QlineArgent(排列:焊盘,x1:0.4,y1:0.5,x2:0.6,y2:0.5,停止:0 rgba(115,115,115,255),停止:1 rgba(62,62,62255));
左边框颜色:QlineArgent(排列:焊盘,x1:0.6,y1:0.5,x2:0.4,y2:0.5,停止:0 rgba(115,115,115,255),停止:1 rgba(62,62,62,255));
边框底色:rgb(58,58,58);
边框底宽:1px;
边框样式:实心;
颜色:rgb(255、255、255);
填充:6px;
背景色:QlineArgent(排列:pad,x1:0.5,y1:1,x2:0.5,y2:0,停止:0 rgba(77,77,77,255),停止:1 rgba(97,97,97,255));
}
QPushButton:禁用{
边界样式:开始;
边框宽度:2倍;
边框顶部颜色:QlineArgent(排列:焊盘,x1:0.5,y1:0.6,x2:0.5,y2:0.4,停止:0 rgba(115,115,115,255),停止:1 rgba(62,62,62,255));
右边框颜色:QlineArgent(排列:焊盘,x1:0.4,y1:0.5,x2:0.6,y2:0.5,停止:0 rgba(115,115,115,255),停止:1 rgba(62,62,62255));
左边框颜色:QlineArgent(排列:焊盘,x1:0.6,y1:0.5,x2:0.4,y2:0.5,停止:0 rgba(115,115,115,255),停止:1 rgba(62,62,62,255));
边框底色:rgb(58,58,58);
边框底宽:1px;
边框样式:实心;
颜色:rgb(0,0,0);
填充:6px;
背景色:QlineArgent(排列:pad,x1:0.5,y1:1,x2:0.5,y2:0,停止:0 rgba(57,57,57,255),停止:1 rgba(77,77,77,255));
}
QLineEdit{
边框宽度:1px;边框半径:4px;
边框颜色:rgb(58,58,58);
边框样式:插图;
填充:0 8px;
颜色:rgb(255、255、255);
背景:rgb(101、101、101);
选择背景色:rgb(187187187187);
选择颜色:rgb(60,63,65);
}
QProgressBar{
文本对齐:居中;
颜色:rgb(255、255、255);
边框宽度:1px;
边界半径:10px;
边框颜色:rgb(58,58,58);
边框样式:插图;
}
QProgressBar::chunk{
背景色:QlineArgent(排列:焊盘,x1:0.5,y1:0.7,x2:0.5,y2:0.3,停止:0 rgb(255,0,0),停止:1 rgb(255,0,0));
边界半径:10px;
}
QMenuBar{
背景:rg