pyside

Replace CentralWidget in MainWindow

半世苍凉 提交于 2019-12-03 13:42:22
I'm kinda new to PySide.I have a main window object which shows one widget at a time. I've been trying to change the central widget of the QMainWindow class in order to replace the visible Widget in the window when pressing a button. The problem is that the button pressed is in the Widget class, not in the main window class. say... class App(QtGui.QMainWindow): def __init__(self): super(App, self).__init__() self.initUI() def initUI(self): self.statusBar().showMessage('Listo.') #Status Bar self.login_screen = LoginScreen() self.logged_in_screen = LoggedInScreen() self.setCentralWidget(self

Make an animated wave with drawPolyline in PySide/PyQt

自作多情 提交于 2019-12-03 13:25:32
问题 I'm trying to animate a polyline (it have to act like a wave). I've tried this way: from PySide.QtCore import * from PySide.QtGui import * import sys, time class Test(QMainWindow): def __init__(self, parent=None): QMainWindow.__init__(self, parent) def poly(self, pts): return QPolygonF(map(lambda p: QPointF(*p), pts)) def paintEvent(self, event): painter = QPainter(self) pts = [[80, 490], [180, 0], [280, 0], [430, 0], [580, 0], [680, 0], [780, 0]] for i in pts: while i[1] < 600: painter

QImage to Numpy Array using PySide

巧了我就是萌 提交于 2019-12-03 13:19:16
问题 I am currently switching from PyQt to PySide. With PyQt I converted QImage to a Numpy.Array using this code that I found on SO: def convertQImageToMat(incomingImage): ''' Converts a QImage into an opencv MAT format ''' incomingImage = incomingImage.convertToFormat(4) width = incomingImage.width() height = incomingImage.height() ptr = incomingImage.bits() ptr.setsize(incomingImage.byteCount()) arr = np.array(ptr).reshape(height, width, 4) # Copies the data return arr However ptr.setsize

How to make a widget in the center of the screen in PySide/PyQt?

亡梦爱人 提交于 2019-12-03 11:32:54
问题 This code works, but I wonder if there is any simpler way: def center(self): qr = self.frameGeometry() cp = gui.QDesktopWidget().availableGeometry().center() qr.moveCenter(cp) self.move(qr.topLeft()) 回答1: No, it's the simplest way. Here is a snippet I've used in C++: QRect desktopRect = QApplication::desktop()->availableGeometry(this); QPoint center = desktopRect.center(); move(center.x() - width() * 0.5, center.y() - height()); 回答2: just add this line to your main windows : self.move(QtGui

PySide集成开发环境下载安装配置

爷,独闯天下 提交于 2019-12-03 09:00:03
现在学习python pyside 等,边学边写呵,大侠们都不屑呵,我先写一篇 摸索了一段时间,用了不同的GUI库和集成开发环境还是这个简单 下载地址: http://www.python.org/ http://pypi.python.org/pypi/distribute (python3需要装这个) http://qt-project.org/wiki/PySide http://eric-ide.python-projects.org/eric-download.html 在window下安装都简单文件列表如下: python-3.3.0.msi PySide-1.1.2.win32-py3.3.exe distribute-0.6.34.tar.gz 解压后看readme.text安装 下面两个解压后合并后安装 eric5-5.2.7.zip eric5-i18n-zh_CN.GB2312-5.2.7.zip eric5需要PyQt4支持呵,PyQt4有两个许可证,可以看看 PyQt4 http://www.riverbankcomputing.co.uk/software/pyqt/download 下载后的文件列表: PyQt-Py3.3-x86-gpl-4.9.6-1.exe 维基百科: PySide 是跨平台的应用程式框架 Qt 的 Python 绑定版本 。

Pyside with Python 3 Mac OS 10.8

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm new at programing but I tried to find the answer for a week and could not solve my issue that seems to be easy. I have a Macbook air with OS 10.8 and installed via Brew Python3 and Pyside using: brew install pyside --with-python3 It install ok but when I try to import Pyside from terminal or from Pcharm it says: File "", line 1, in ImportError: No module named 'pyside' I know that it may seem simple, but I tried everything I found in the web but nothing works. This time I reinstall a clean version of my OS to have a clean install and the

Creating MSI with cx_freeze and bdist_msi for PySide app

烂漫一生 提交于 2019-12-03 08:25:24
I have a PySide application that I'm trying to package into an MSI using cx_freeze. I can successfully create an MSI installer, but I'm having trouble figuring out how to list additional modules to be included in the package. Here's my setup.py script: import sys from cx_Freeze import setup, Executable company_name = 'My Company Name' product_name = 'My Gui' bdist_msi_options = { 'upgrade_code': '{66620F3A-DC3A-11E2-B341-002219E9B01E}', 'add_to_path': False, 'initial_target_dir': r'[ProgramFilesFolder]\%s\%s' % (company_name, product_name), # 'includes': ['atexit', 'PySide.QtNetwork'], # <--

PySide + QTableView example

痞子三分冷 提交于 2019-12-03 07:58:37
问题 Can anyone point me to a simple example of QTableView in PySide? I found the QTableView docs but unfortunately they don't give an example, and I'm very new to PySide, so I don't even know how to start. (I am very familiar with the JTable in Java Swing, so I know how to use table models.) 回答1: Found one: http://www.daniweb.com/software-development/python/code/447834/applying-pysides-qabstracttablemodel ''' ps_QAbstractTableModel_solvents.py use PySide's QTableView and QAbstractTableModel for

calling a parent method from a child widget in pyside/pyqt

て烟熏妆下的殇ゞ 提交于 2019-12-03 07:39:52
I'm trying to call a method of a parent class from within a child class. Specifically, my parent class is a PySide.QtGui.QMainWindow object, and my child class is a PySide.QtGui.QWidget object; the latter is set to be the central widget of the former. I'm trying to connect a button within the child to a method in the parent class. This has worked for me in the past using self.parent().method_name , but it doesn't work in the example below and I don't understand why: import sys from PySide import QtGui, QtCore class MainWindow(QtGui.QMainWindow): def __init__(self): super(MainWindow, self)._

PyQt (PySide), WebKit and exposing methods from/to Javascript

爷,独闯天下 提交于 2019-12-03 07:30:39
问题 I am planning to use PyQt to control an embedded WebKit browser on the server side. I have some inherit application logic in Javascript in the HTML page running inside WebKit. How could I communicate from the host process (Python, PyQt) with Javascript, so that I can call Javascript functions inside the page Python methods are exposed to Javascript and can be called from the Javascript, with arguments 回答1: The following source code should be helpful: import sys from PyQt4.QtCore import