PYQT窗口居中
#UI.py,通过UI设计师制作后直接转换为UI.py脚本
# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(400, 300)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
#Main.py,可视化UI.py
# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui, Qt
from UI import *
class MainWindow(QtGui.QMainWindow):
def __init__(self,parent=None):
QtGui.QWidget.__init__(self,parent)
self.ui=Ui_Form()
self.ui.setupUi(self)
#窗口居中显示
desktop =QtGui.QApplication.desktop()
width = desktop.width()
height = desktop.height()
self.move((width - self.width())/2, (height - self.height())/2)
self.setMouseTracking(True)
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
myapp=MainWindow()
myapp.show()
app.exec_()
PYQT窗口居中的更多相关文章
- window.open窗口居中和窗口最大化
1.window.open()参数 window.open(pageURL,name,parameters) 其中: pageURL为子窗口路径 name为子窗口句柄 parameters为窗口参数( ...
- Example005控制弹出窗口居中显示
<!-- 实例005控制弹出窗口居中显示 --> <head> <meta charset="UTF-8"> </head> < ...
- WPF 窗口居中 & 变更触发机制
窗口居中 & 变更触发机制 解决: 1.单实例窗口,窗口每次隐藏后再显示时,位置居中显示 2.多屏幕下单实例窗口,当父窗口移动到其它屏幕时,单实例窗口再次弹出时,位置才更新到父窗口屏幕. 3. ...
- tkinter窗口居中方法
tkinter窗口居中 from tkinter import * class MyFrm(Frame): def __init__(self, master): self.root=master s ...
- 【Qt】窗口居中显示
w.move((a.desktop()->width() - w.width())/, (a.desktop()->height() - w.height())/); 上述方法可以置中,但 ...
- python之tkinter使用-窗口居中显示
# 窗口居中显示 import tkinter as tk def set_win_center(root, curWidth='', curHight=''): ''' 设置窗口大小,并居中显示 : ...
- Qt 设置窗口居中显示和窗体大小
设置窗口居中显示 方法一:在窗口(QWidget类及派生类)的构造函数中添加如下代码: #include <QDesktopWidget> //....... QDesktopWidget ...
- Pyqy5 让窗口居中
# QDesktopWidget import sys from PyQt5.QtWidgets import QDesktopWidget,QMainWindow,QApplication from ...
- Java_Swing中让窗口居中显示的方法(三种方法)
方法一: int windowWidth = frame.getWidth(); // 获得窗口宽 int windowHeight = frame.getHeight(); // 获得窗口高 ...
随机推荐
- numpy之ones,array,asarray
from:http://blog.csdn.net/gobsd/article/details/56485177 numpy.ones() 废话少说直接上代码 >>> np.ones ...
- linux用户权限 -> 系统用户管理
用户基本概述: Linux用户属于多用户操作系统,在windows中,可以创建多个用户,但不允许同一时间多个用户进行系统登陆,但是Linux可以同时支持多个用户同时登陆操作系统,登陆后互相之间并不影响 ...
- MySQL基础 - Navicat及HeidiSQL可视化数据库管理工具
你还在使用终端界面查看数据库吗?是的,用来用去还是觉得命令行好用.....这里先留个位子,改天再介绍下这俩工具的使用,虽然好像觉得没啥需要介绍的.
- Java 容器的基本概念
java容器类类库的用途时"保存对象",并将其划分为两个不同的概念: 1)Collection(采集).一个独立元素的序列,这些元素都服从一条或多条规则,List必须按照插入的顺序 ...
- opencv(4)实现数据增加小工具
数据增加(data augmentation),作为一种深度学习中的常用手段,数据增加对模型的泛化性和准确性都有帮助.数据增加的具体使用方式一般有两种,一种是实时增加,比如在Caffe中加入数据扰动层 ...
- SCTP客户端与服务器
/** * @brief - Send a message, using advanced SCTP features * The sctp_sendmsg() function allows you ...
- Mysql建表语句
create table messages( id int unsigned primary key auto_increment, sender varchar(64) not null, gett ...
- shell 中>/dev/null 2>&1含义
shell中可能经常能看到:>/dev/null 2>&1 命令的结果可以通过%>的形式来定义输出 分解这个组合:“>/dev/null 2>&1” 为五 ...
- python 统计MySQL表信息
一.场景描述 线上有一台MySQL服务器,里面有几十个数据库,每个库有N多表. 现在需要将每个表的信息,统计到excel中,格式如下: 库名 表名 表说明 建表语句 db1 users 用户表 CRE ...
- centos6.5/6.3升级安装ImageMagick7.0.1-1
线上论坛和应用程序的验证码功能都是使用的ImageMagick,但是版本比较老(centos yum安装的ImageMagick6.5.9).接到最新漏洞预报,紧急升级! ImageMagick图象处 ...