Python Qt - MedTec4SusDev – MACbioIDi.eu

2y ago
140 Views
15 Downloads
386.17 KB
18 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Jacoby Zeller
Transcription

PythonQtMACbioIDi – February – March 2018

Qt Framework Qt is a cross-platform application developmentframework:– Can be used for application development for a widerange of target platformsIt is a framework written in C –Preprocessor MOC (Meta-Object Compiler) is usedto extend the C language2

Qt Framework Libraries and development tools in order todevelop multiple task:–Graphical user interfaces–Networking–Threads–Regular Expressions–OpenGL–XML.3

Qt Framework Qt Company–Started in 1990 by Eirik Chambe-Eng and HaavardNord as Trolltech–Main driver behind QtQt Project–A meritocratic, consensus-based communityinterested in Qt–There are many companies and individuals aroundthe globe4

Commercial and OpenSource Commercial – costs money–Your application can be closed–Changes to Qt can be kept closedGPL – free–Your application must be open–Changes to Qt must be fedback to the communityLGPL – free–Your application can be open or closed–Changes to Qt must be fedback to the community5

PyQt5 PyQt5 is a binding of Qt 5 framework– Python Wrapper generated using SIP binding generatorComponents:–Modules for different purposes–Plugins that enable Qt Designer and qmlscene to be extendedusing Python code–Utility programs: Pyuic5Pyrcc5pyupdate56

Qt Designer Qt comes with its own IDE, Qt Creator, and atool to design and building GUIs, Qt Designer7

Get familiar with QtDesigner Qt Designer generates a XML file– Pyuic parse the XML file and generates the pythoncodeWe can generate the python code directly–It is a more complicated option to maintain longterm8

Example We will create a simple widget that contains aPush Button9

Example Create your own window for you application:–Create a python class that inherits fromQMainWindow–Uses the Pyuic5 in order to relation your ui file withthe class The ui file was generated with Qt DesignerCreate the QApplication that will show ourwindow10

Exampleimport sysfrom PyQt5.QtWidgets import QmainWindowfrom PyQt5 import uicclass MyWindow(QMainWindow):def init (self):QMainWindow. init (self)uic.loadUi(“[Path to your file]”, self)self.setWindowTitle("MyWindow")app QApplication(sys.argv)mainWindow MyWindow()mainWindow.show()app.exec()11

Example12

Get familiar with QtDesigner13

Signals and Slots Used for communication between objects–Thanks to Qt’s meta-object system (MOC)–Signals can transmit variables values14

Signals and Slots Emitted by an object when its internal state haschanged–Public access–Can be emmited from anywhereSignals are automatically generated by the MOC– They can never have return typesSlots are called when a signal connected to it isemited–Slots can be called like a method too15

Signals and SlotsExample#include QObject class Counter : public QObject{Q OBJECTpublic:Counter() { m value 0; }int value() const { return m value; }from PyQt5.Qt import QObject, pyqtSlot,pyqtSignalclass Counter(QObject):valueChanged pyqtSignal(int)def init (self):self.value 0public slots:void setValue(int value);def value(self):return self.valuesignals:void valueChanged(int newValue);@pyqtSlot(int)def setValue(self, value):self.value valueprivate:int m value;};16

Signal and SlotsExercise We will create a very simple text viewer from our examplegenerated in this session–Assign actions to the QToolButtons and QpushButtons–Generates a new thread in order to read the files It will not block the GUI if we read a larger fileTake a look to:–QFileDialog.getOpenFilename()–QFile class–QAction class–QPushButton class–QThread class17

PythonQtMACbioIDi – February – March 2018

PyQt5 PyQt5 is a binding of Qt 5 framework – Python Wrapper generated using SIP binding generator Components: – Modules for different purposes – Plugins that enable Qt Designer and qmlscene to be extended usin

Related Documents:

Python Programming for the Absolute Beginner Second Edition. CONTENTS CHAPTER 1 GETTING STARTED: THE GAME OVER PROGRAM 1 Examining the Game Over Program 2 Introducing Python 3 Python Is Easy to Use 3 Python Is Powerful 3 Python Is Object Oriented 4 Python Is a "Glue" Language 4 Python Runs Everywhere 4 Python Has a Strong Community 4 Python Is Free and Open Source 5 Setting Up Python on .

Python 2 versus Python 3 - the great debate Installing Python Setting up the Python interpreter About virtualenv Your first virtual environment Your friend, the console How you can run a Python program Running Python scripts Running the Python interactive shell Running Python as a service Running Python as a GUI application How is Python code .

Python is readable 5 Python is complete—"batteries included" 6 Python is cross-platform 6 Python is free 6 1.3 What Python doesn't do as well 7 Python is not the fastest language 7 Python doesn't have the most libraries 8 Python doesn't check variable types at compile time 8 1.4 Why learn Python 3? 8 1.5 Summary 9

site "Python 2.x is legacy, Python 3.x is the present and future of the language". In addition, "Python 3 eliminates many quirks that can unnecessarily trip up beginning programmers". However, note that Python 2 is currently still rather widely used. Python 2 and 3 are about 90% similar. Hence if you learn Python 3, you will likely

There are currently two versions of Python in use; Python 2 and Python 3. Python 3 is not backward compatible with Python 2. A lot of the imported modules were only available in Python 2 for quite some time, leading to a slow adoption of Python 3. However, this not really an issue anymore. Support for Python 2 will end in 2020.

A Python Book A Python Book: Beginning Python, Advanced Python, and Python Exercises Author: Dave Kuhlman Contact: dkuhlman@davekuhlman.org

Mike Driscoll has been programming with Python for more than a decade. He has been writing about Python on his blog, The Mouse vs. The Python, for many years. Mike is the author of several Python books including Python 101, Python Interviews, and ReportLab: PDF Processing with Python. You can find Mike on Twitter or GitHub via his handle .

learning teams, guided inquiry activities, critical and analytical thinking, problem solving, reporting, metacognition, and individual responsibility. Strategies for the successful use of learning teams are discussed, the roles of the instructor in this learning environment are described, and implementation hints