QThread Windows not responding

I wrote a GUI program in PyQt on Windows. There's some expensive operations in my program. While these operations are running, the program shows "Not Responding" in the program bar. I think it must be this operation block the main thread to update the UI, so I write multi-threading code by QThread to test it, it still not make sense. I wrote a small program to test it, the ope

QThread Windows没有响应

我在Windows上的PyQt中编写了一个GUI程序。 我的程序中有一些昂贵的操作。 在这些操作正在运行时,程序在程序栏中显示“Not Responding”。 我认为它必须是这个操作块来更新UI的主线程,所以我用QThread编写多线程代码来测试它,但它仍然没有意义。 我写了一个小程序来测试它,这个操作并没有在新线程中运行,这里是我的小测试代码: from PyQt5.QtCore import QThread, QObject, QCoreApplication, qDebug, QTimer class

How to resize the QMenuBar in PyQt4 for a 4K display

I need to write an application in Python with a User Interface. I decided to go for PyQt4 to make the GUI. It is included in the Anaconda distribution of Python. To make a GUI running smoothly on a 4K display is not trivial. Most components are way too small by default. Some components - like buttons - are easy to resize: btn = QtGui.QPushButton("Quit", self) btn.resize(100,100) But how d

如何在PyQt4中调整QMenuBar的4K显示

我需要用Python编写一个带有用户界面的应用程序。 我决定去PyQt4制作GUI。 它包含在Python的Anaconda发行版中。 要在4K显示器上平滑地运行GUI并不是微不足道的。 默认情况下,大多数组件的方式太小。 有些组件 - 比如按钮 - 很容易调整大小: btn = QtGui.QPushButton("Quit", self) btn.resize(100,100) 但是如何调整其他组件的大小,比如QMenuBar? 我可以使QMenuBar的QMenu按钮(比如“文件”,“编辑”,..)填充更大的

PyQt can't set a value for an object from a dialog in main window

I have a Main program that calls various Dialogs with their own GUIs. Basically what I want to do is to set up a value in Main for an object that is another class: class ZoneManager(QMainWindow, mainWindow.Ui_zzzMainWindow): def __init__(self): QMainWindow.__init__(self) mainWindow.Ui_zzzMainWindow.__init__(self) ..... def cookie_find(self): match = re.search

PyQt无法为主窗口中的对话框中的对象设置值

我有一个主程序用他们自己的GUI调用各种对话框。 基本上我想要做的是在Main中为另一个类设置一个值: class ZoneManager(QMainWindow, mainWindow.Ui_zzzMainWindow): def __init__(self): QMainWindow.__init__(self) mainWindow.Ui_zzzMainWindow.__init__(self) ..... def cookie_find(self): match = re.search('cookie_id=(.*?)"', page).group(1) rga = str(match)

PyQT4: getting text from Ui for existing python program

I'm trying to create a UI for an existing python program that I've made. On the widget, I have two text boxes (QlineEdit) that I want to use to get the information for the program to use, a button and a textbrowser that will hold the output of the program. I've stumbled upon PyQT4, which I installed using homebrew, and QT Creator. I've created the UI and converted it from a ma

PyQT4:从现有的python程序获取来自Ui的文本

我正在尝试为我创建的现有python程序创建一个UI。 在小部件上,我有两个文本框(QlineEdit),我想用它来获取程序使用的信息,一个按钮和一个用于保存程序输出的文本浏览器。 我偶然发现了使用自制软件安装的PyQT4和QT Creator。 我创建了UI并将其从mainwindow.ui转换为mainwindow.py,现在我试图弄清楚如何从UI文本框中获取文本输入并让程序使用它。 我不知道如何从文本框中提取文本(QlineEdit)并将它们存储在程序可以

Multiple windows in PyQt4?

I've just begun using pyqt4. I followed a tutorial (http://zetcode.com/tutorials/pyqt4/) One thing that puzzles me is this part: def main(): app = QtGui.QApplication(sys.argv) ex = GUI() sys.exit(app.exec()) And the reason for this I explain here: I have made a small program that opens four more windows except for the first main window. So I tried to replicate what I saw wor

PyQt4中有多个窗口?

我刚开始使用pyqt4。 我跟着一个教程(http://zetcode.com/tutorials/pyqt4/)让我感到困惑的是这部分: def main(): app = QtGui.QApplication(sys.argv) ex = GUI() sys.exit(app.exec()) 我在这里解释的原因是: 我做了一个小程序,除了第一个主窗口外,还打开了四个窗口。 所以我试图复制我看到的与main-window一起工作的内容,并为每个新窗口创建一个类,并试图像上面那样做。 目前看起来像这样: def m

Understanding pyqtProperty in PyQt4

I wrote the following little script to understand properties. One thing which I cannot understand is, that the metaObject() of my class A contains a property with the name conf_name now. How did it get that information? In my class it is only used once as name for the target variable of the call to set the property. How can this be realized? Can it also be realized with plain Python, ie with

了解PyQt4中的pyqtProperty

我写了下面的小脚本来理解属性。 我无法理解的一件事是,我的类A的metaObject()现在包含名称为conf_name的属性。 它是如何得到这些信息的? 在我的课程中,它只被用作调用目标变量的名称来设置属性。 这怎么能被实现? 它是否也可以用普通的Python实现,即没有C API? #!/usr/bin/python from PyQt4.QtCore import QObject, pyqtProperty from PyQt4.QtGui import QApplication class A( QObject ): def __init__( se

Maintainability of a python wrapping of a C library

I have a poorly designed and big ( > 300 public functions , >200 numeric constants defined with #define in the header file) that I have to wrap in Python. I have the dll and the h file. The library is updated yearly, till now in a backwards compatible way (ie just functions were added, a constant keep their numerical values, etc). But I have no guarantees as I do not control the library.

一个C库的python包装的可维护性

我有一个设计不好的大型( > 300 public functions ,在头文件中用#define定义的>200 numeric constants ),我必须用Python进行封装。 我有dll和h文件。 该库每年更新一次,直到现在以向后兼容的方式(即只添加了函数,常量保持它们的数值等)。 但我没有保证,因为我不控制图书馆。 使用ctypes ,我看到了两种用Python包装的方法: 将每个常量和函数映射到python,1到1 用Python重新定义API并调用库。 第一个

Why doesn't matplotlib use the .ttf font that I provide?

I'm trying to use a TTF font in matplotlib; the .ttf file is downloaded and lives locally on my machine. I've followed other instructions on this site for selecting the font using font_manager ; however, any text that I generate trying to use the font properties still appears in the default matplotlib font. I know that Python does successfully find the font file, since prop.get_name(

为什么matplotlib不使用我提供的.ttf字体?

我试图在matplotlib中使用TTF字体; .ttf文件被下载并在我的机器上本地存在。 我已经按照本网站上的其他说明使用font_manager选择了字体; 但是,我尝试使用字体属性的任何文本仍然以默认的matplotlib字体显示。 我知道Python能够成功找到字体文件,因为prop.get_name()和类似的命令确实显示了我想要的字体的属性 - 但这并不是我的图中出现的。 有什么建议么? 举个例子: import matplotlib.pyplot as plt import matplot

Descriptors : Precendence of Attribute access through

I can't understand what does the below precedence means in context of __getattribute__() special method and Descriptors I read this under the topic("Precedence") - under topic ("Desriptors") from book Core Python Programming 3 times, still can't get through it.. Can any one explain what are these precedence, and where they are used for?? Class attributes Data des

描述符:通过属性访问的优先级

我无法理解下面的优先级在__getattribute__()特殊方法和Descriptors情况下意味着什么 我在topic("Precedence") - under topic ("Desriptors")核心Python编程topic("Precedence") - under topic ("Desriptors")一书的topic("Precedence") - under topic ("Desriptors")下topic("Precedence") - under topic ("Desriptors")阅读了这个topic(&q

How do you change the size of figures drawn with matplotlib?

你如何改变用matplotlib绘制的图形的大小? figure tells you the call signature: figure(num=None, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k') So figure(figsize=(1,1)) creates an inch-by-inch image, which will be 80-by-80 pixels unless you also give a different dpi argument. If you've already got the figure created you can quickly do this: fig = matplotlib.pyplot.gcf() fig.set_size

你如何改变用matplotlib绘制的图形的大小?

你如何改变用matplotlib绘制的图形的大小? 图告诉你呼叫签名: figure(num=None, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k') 所以figure(figsize=(1,1))会创建一个每英寸的图像,除非您还提供了不同的dpi参数,否则该图像将为80 x 80像素。 如果你已经创建了这个图形,你可以快速做到这一点: fig = matplotlib.pyplot.gcf() fig.set_size_inches(18.5, 10.5) fig.savefig('test2png.png', dpi=100) 要将大