├── src ├── table_tree │ ├── TreeView.py │ ├── images │ │ ├── IOS.png │ │ ├── bao0.png │ │ ├── bao1.png │ │ ├── bao10.png │ │ ├── bao11.png │ │ ├── bao12.png │ │ ├── bao13.png │ │ ├── bao14.png │ │ ├── bao2.png │ │ ├── bao3.png │ │ ├── bao4.png │ │ ├── bao5.png │ │ ├── bao6.png │ │ ├── bao7.png │ │ ├── bao8.png │ │ ├── bao9.png │ │ ├── flower.png │ │ ├── hammer.png │ │ ├── music.png │ │ ├── root.png │ │ └── cartoon1.ico │ ├── ListWidget.py │ ├── ListView.py │ ├── Span.py │ ├── CellImageText.py │ ├── TreeEvent.py │ ├── TableView.py │ ├── CellImageSize.py │ ├── CellTextAlignment.py │ ├── DataLocation.py │ ├── CellFontAndColor.py │ ├── CellSize.py │ ├── PlaceControlInCell.py │ ├── BasicTreeWidget.py │ └── TableWidget.py ├── Test.py ├── controls │ ├── 屏幕坐标系.txt │ ├── images │ │ ├── doc.ico │ │ ├── new.png │ │ ├── win.png │ │ ├── Golem.ico │ │ ├── Logo.ico │ │ ├── Troll.ico │ │ ├── close.ico │ │ ├── open.png │ │ ├── save.png │ │ ├── Archer.ico │ │ ├── Banshee.ico │ │ ├── Basilisk.ico │ │ ├── Djinni.ico │ │ ├── Dragon.ico │ │ ├── Goblin.ico │ │ ├── Knight.ico │ │ ├── Phoenix.ico │ │ ├── Unicorn.ico │ │ ├── Valkyrie.ico │ │ ├── Wizard.ico │ │ ├── printer.png │ │ ├── python.jpg │ │ ├── python.png │ │ ├── screen.png │ │ ├── Game Board.ico │ │ ├── Manticore.ico │ │ ├── Sorceress.ico │ │ ├── Air Elemental.ico │ │ ├── Shapeshifter.ico │ │ ├── ajax-loading.gif │ │ ├── Earth Elemental.ico │ │ ├── Fire Elemental.ico │ │ ├── Water Elemental.ico │ │ ├── Power Point (Dark).ico │ │ └── Power Point (Light).ico │ ├── 主窗口类型.txt │ ├── FirstMainWin.py │ ├── IconForm.py │ ├── CenterForm.py │ ├── Tooltip.py │ ├── QuitApplication.py │ ├── QSpinBoxDemo.py │ ├── QRadioButtonDemo.py │ ├── QLabelBuddy.py │ ├── QComboBoxDemo.py │ ├── ScreenGeometry.py │ ├── QLineEditEchoMode.py │ ├── QLineEditDemo.py │ ├── QTextEditDemo.py │ ├── QLineEditMask.py │ └── QLineEditValidator.py ├── windows │ ├── QDarkStyleSheet-master │ │ ├── qdarkstyle │ │ │ ├── .gitignore │ │ │ ├── rc │ │ │ │ ├── close.png │ │ │ │ ├── undock.png │ │ │ │ ├── sizegrip.png │ │ │ │ ├── up_arrow.png │ │ │ │ ├── branch_open.png │ │ │ │ ├── close-hover.png │ │ │ │ ├── down_arrow.png │ │ │ │ ├── left_arrow.png │ │ │ │ ├── right_arrow.png │ │ │ │ ├── transparent.png │ │ │ │ ├── Hmovetoolbar.png │ │ │ │ ├── Hsepartoolbar.png │ │ │ │ ├── Vmovetoolbar.png │ │ │ │ ├── Vsepartoolbar.png │ │ │ │ ├── branch_closed.png │ │ │ │ ├── branch_open-on.png │ │ │ │ ├── close-pressed.png │ │ │ │ ├── radio_checked.png │ │ │ │ ├── branch_closed-on.png │ │ │ │ ├── checkbox_checked.png │ │ │ │ ├── radio_unchecked.png │ │ │ │ ├── stylesheet-vline.png │ │ │ │ ├── checkbox_unchecked.png │ │ │ │ ├── down_arrow_disabled.png │ │ │ │ ├── left_arrow_disabled.png │ │ │ │ ├── radio_checked_focus.png │ │ │ │ ├── up_arrow_disabled.png │ │ │ │ ├── radio_unchecked_focus.png │ │ │ │ ├── right_arrow_disabled.png │ │ │ │ ├── stylesheet-branch-end.png │ │ │ │ ├── checkbox_checked_focus.png │ │ │ │ ├── checkbox_indeterminate.png │ │ │ │ ├── checkbox_unchecked_focus.png │ │ │ │ ├── radio_checked_disabled.png │ │ │ │ ├── radio_unchecked_disabled.png │ │ │ │ ├── stylesheet-branch-more.png │ │ │ │ ├── checkbox_checked_disabled.png │ │ │ │ ├── checkbox_indeterminate_focus.png │ │ │ │ ├── checkbox_unchecked_disabled.png │ │ │ │ └── checkbox_indeterminate_disabled.png │ │ │ └── style.qrc │ │ ├── setup.cfg │ │ ├── stdeb.cfg │ │ ├── example │ │ │ ├── ui │ │ │ │ ├── __init__.py │ │ │ │ └── compile_ui.sh │ │ │ └── example_pyqt5.spec │ │ ├── screenshots │ │ │ ├── 01.png │ │ │ ├── QDarkStyle example 1.png │ │ │ └── QDarkStyle example 2.png │ │ ├── MANIFEST.in │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── makeppa.sh │ │ ├── COPYING │ │ └── PKGBUILD │ ├── images │ │ ├── add.png │ │ ├── boy.png │ │ ├── dog.jpg │ │ ├── dog2.jpg │ │ ├── down.png │ │ ├── left.png │ │ ├── mask.png │ │ ├── up.png │ │ ├── up2.png │ │ ├── up3.png │ │ ├── down2.png │ │ ├── down3.png │ │ ├── left2.png │ │ ├── left3.png │ │ ├── leftup.png │ │ ├── mask2.png │ │ ├── python.jpg │ │ ├── right.png │ │ ├── right2.png │ │ ├── right3.png │ │ ├── addhover.png │ │ ├── cartoon1.ico │ │ ├── cartoon2.ico │ │ ├── cartoon3.ico │ │ ├── cartoon4.ico │ │ ├── dropdown.png │ │ ├── leftHover.png │ │ ├── leftdown.png │ │ ├── leftdown2.png │ │ ├── leftdown3.png │ │ ├── leftup2.png │ │ ├── leftup3.png │ │ ├── loading.gif │ │ ├── rightdown.png │ │ ├── rightup.png │ │ ├── rightup2.png │ │ ├── rightup3.png │ │ ├── screen1.jpg │ │ ├── screen2.jpg │ │ ├── Cloudy_72px.png │ │ ├── leftPressed.png │ │ ├── rightdown2.png │ │ ├── rightdown3.png │ │ └── square_add.png │ ├── 屏幕快照 2018-12-09 上午10.19.22.png │ ├── CommonHelper.py │ ├── style.qss │ ├── OpacityWindow.py │ ├── Background1.py │ ├── Background2.py │ ├── WindowPattern.py │ ├── gitanim.py │ ├── Background.py │ ├── QSSSubControl.py │ ├── BasicQSS.py │ ├── ScaleImage.py │ ├── LoadQSS.py │ ├── MoveWindow.py │ ├── WindowStyle.py │ ├── LabelButtonBackground.py │ ├── QSSSelector.py │ ├── AnimWindow.py │ ├── WindowMaxMin.py │ ├── AbnormityWindow.py │ └── DarkStyleSheet.py ├── ext │ ├── db │ │ └── database.db │ ├── pyinstaller.txt │ ├── MyDB.py │ ├── pyqtgraph_pyqt.ui │ ├── pyqtgraph_pyqt.py │ └── DataGrid.py ├── drawing │ ├── images │ │ ├── book.png │ │ └── book1.png │ ├── DrawPoints.py │ ├── DrawText.py │ ├── FillRect.py │ ├── DrawMultiLine.py │ └── DrawAll.py ├── drapclip │ ├── images │ │ ├── book.png │ │ └── book1.png │ └── DrapDrop.py ├── basic │ ├── 开发第一个基于PyQt5的桌面应用.txt │ ├── 搭建PyQt5开发环境.txt │ └── First.py ├── menu_toolbar_statusbar │ ├── images │ │ ├── Logo.ico │ │ ├── doc.ico │ │ ├── new.png │ │ ├── open.png │ │ ├── save.png │ │ ├── win.png │ │ ├── Archer.ico │ │ ├── Djinni.ico │ │ ├── Dragon.ico │ │ ├── Goblin.ico │ │ ├── Golem.ico │ │ ├── Knight.ico │ │ ├── Troll.ico │ │ ├── Wizard.ico │ │ ├── close.ico │ │ ├── python.jpg │ │ ├── python.png │ │ ├── screen.png │ │ ├── Banshee.ico │ │ ├── Basilisk.ico │ │ ├── Manticore.ico │ │ ├── Phoenix.ico │ │ ├── Sorceress.ico │ │ ├── Unicorn.ico │ │ ├── Valkyrie.ico │ │ ├── printer.png │ │ ├── Game Board.ico │ │ ├── Air Elemental.ico │ │ ├── Fire Elemental.ico │ │ ├── Shapeshifter.ico │ │ ├── ajax-loading.gif │ │ ├── Earth Elemental.ico │ │ ├── Water Elemental.ico │ │ ├── Power Point (Dark).ico │ │ └── Power Point (Light).ico │ ├── Menu.py │ ├── StatusBar.py │ └── Toolbar.py ├── designer │ ├── 将.ui文件转换为.py文件.txt │ ├── RunMainWinBuddy.py │ ├── RunMainWinTabOrder.py │ ├── RunMainWinVHLayout.py │ ├── RunMainWinFormLayout.py │ ├── RunMainWinGridLayout.py │ ├── RunMainWinSignalSlot.py │ ├── RunMainWinSizePolicy.py │ ├── RunMainWinSpacerLine.py │ ├── 在Qt Designer中设置信号与槽.txt │ ├── RunMainWinMenuToolbar.py │ ├── RunMainWinAbsoluteLayout.py │ ├── RunMainWinVerticalLayout.py │ ├── RunMainWinContainerLayout.py │ ├── RunMainWinHorizontalLayout.py │ ├── 尺寸策略.txt │ └── MainWinMaxMinSize.ui ├── web │ ├── factorial.py │ ├── test.html │ ├── MySharedObject.py │ ├── LocalHTML.py │ ├── WebEngineView.py │ ├── InnerHTML.py │ ├── f.html │ ├── tt.html │ ├── PyQtCallJS.py │ └── PyFactorial.py ├── project │ ├── getWeatherInfo.py │ └── CallWeatherWin.py ├── multithread │ ├── AutoCloseWindow.py │ ├── ShowTime.py │ └── Counter.py ├── SignalSlot │ ├── OverrideSlot.py │ ├── SignalSlotDemo.py │ ├── WinSignal.py │ ├── CustomSignal.py │ ├── PartialSlotArg.py │ ├── DateDialog.py │ ├── AutoSignalSlot.py │ ├── NNSignal.py │ ├── ThreadUpdateUI.py │ ├── LambdaSlotArg.py │ ├── MultiWindow1.py │ ├── NewDateDialog.py │ ├── MultiWindow2.py │ └── MultiSignal.py ├── layout │ ├── AbsoluteLayout.py │ ├── VBoxLayout.py │ ├── HBoxLayout.py │ ├── FormLayout.py │ ├── Stretch.py │ ├── HBoxLayoutAlign.py │ ├── Calc.py │ ├── Calc.spec │ ├── GridForm.py │ ├── RightBottomButton.py │ ├── Splitter.py │ └── Stretch1.py ├── containers │ ├── DockWidget.py │ ├── MultiWindows.py │ └── TabWidget.py ├── dialogs │ ├── QFontDialog.py │ ├── QDialogDemo.py │ ├── QColorDialog.py │ ├── QFileDialogDemo.py │ └── QInputDialogDemo.py ├── printer │ └── PrintSupport.py └── calendar_time │ └── MyCalendar.py ├── documents ├── PyQt5视频课程源代码下载.docx ├── PyQt5视频课程源代码下载.pdf └── 01-初识PyQt5-01-PyQt5简介.pptx └── .idea ├── misc.xml ├── vcs.xml ├── modules.xml └── pyqt5.iml /src/table_tree/TreeView.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Test.py: -------------------------------------------------------------------------------- 1 | print('hello every one.') -------------------------------------------------------------------------------- /src/controls/屏幕坐标系.txt: -------------------------------------------------------------------------------- 1 | 屏幕坐标系 2 | 3 | -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/.gitignore: -------------------------------------------------------------------------------- 1 | /*.pyc 2 | -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/stdeb.cfg: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | Copyright-File: COPYING 3 | -------------------------------------------------------------------------------- /src/ext/db/database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/ext/db/database.db -------------------------------------------------------------------------------- /src/controls/images/doc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/doc.ico -------------------------------------------------------------------------------- /src/controls/images/new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/new.png -------------------------------------------------------------------------------- /src/controls/images/win.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/win.png -------------------------------------------------------------------------------- /src/drawing/images/book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/drawing/images/book.png -------------------------------------------------------------------------------- /src/windows/images/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/add.png -------------------------------------------------------------------------------- /src/windows/images/boy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/boy.png -------------------------------------------------------------------------------- /src/windows/images/dog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/dog.jpg -------------------------------------------------------------------------------- /src/windows/images/dog2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/dog2.jpg -------------------------------------------------------------------------------- /src/windows/images/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/down.png -------------------------------------------------------------------------------- /src/windows/images/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/left.png -------------------------------------------------------------------------------- /src/windows/images/mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/mask.png -------------------------------------------------------------------------------- /src/windows/images/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/up.png -------------------------------------------------------------------------------- /src/windows/images/up2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/up2.png -------------------------------------------------------------------------------- /src/windows/images/up3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/up3.png -------------------------------------------------------------------------------- /documents/PyQt5视频课程源代码下载.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/documents/PyQt5视频课程源代码下载.docx -------------------------------------------------------------------------------- /documents/PyQt5视频课程源代码下载.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/documents/PyQt5视频课程源代码下载.pdf -------------------------------------------------------------------------------- /src/controls/images/Golem.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Golem.ico -------------------------------------------------------------------------------- /src/controls/images/Logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Logo.ico -------------------------------------------------------------------------------- /src/controls/images/Troll.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Troll.ico -------------------------------------------------------------------------------- /src/controls/images/close.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/close.ico -------------------------------------------------------------------------------- /src/controls/images/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/open.png -------------------------------------------------------------------------------- /src/controls/images/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/save.png -------------------------------------------------------------------------------- /src/drapclip/images/book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/drapclip/images/book.png -------------------------------------------------------------------------------- /src/drapclip/images/book1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/drapclip/images/book1.png -------------------------------------------------------------------------------- /src/drawing/images/book1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/drawing/images/book1.png -------------------------------------------------------------------------------- /src/table_tree/images/IOS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/IOS.png -------------------------------------------------------------------------------- /src/windows/images/down2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/down2.png -------------------------------------------------------------------------------- /src/windows/images/down3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/down3.png -------------------------------------------------------------------------------- /src/windows/images/left2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/left2.png -------------------------------------------------------------------------------- /src/windows/images/left3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/left3.png -------------------------------------------------------------------------------- /src/windows/images/leftup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/leftup.png -------------------------------------------------------------------------------- /src/windows/images/mask2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/mask2.png -------------------------------------------------------------------------------- /src/windows/images/python.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/python.jpg -------------------------------------------------------------------------------- /src/windows/images/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/right.png -------------------------------------------------------------------------------- /src/windows/images/right2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/right2.png -------------------------------------------------------------------------------- /src/windows/images/right3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/right3.png -------------------------------------------------------------------------------- /src/controls/images/Archer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Archer.ico -------------------------------------------------------------------------------- /src/controls/images/Banshee.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Banshee.ico -------------------------------------------------------------------------------- /src/controls/images/Basilisk.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Basilisk.ico -------------------------------------------------------------------------------- /src/controls/images/Djinni.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Djinni.ico -------------------------------------------------------------------------------- /src/controls/images/Dragon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Dragon.ico -------------------------------------------------------------------------------- /src/controls/images/Goblin.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Goblin.ico -------------------------------------------------------------------------------- /src/controls/images/Knight.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Knight.ico -------------------------------------------------------------------------------- /src/controls/images/Phoenix.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Phoenix.ico -------------------------------------------------------------------------------- /src/controls/images/Unicorn.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Unicorn.ico -------------------------------------------------------------------------------- /src/controls/images/Valkyrie.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Valkyrie.ico -------------------------------------------------------------------------------- /src/controls/images/Wizard.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Wizard.ico -------------------------------------------------------------------------------- /src/controls/images/printer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/printer.png -------------------------------------------------------------------------------- /src/controls/images/python.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/python.jpg -------------------------------------------------------------------------------- /src/controls/images/python.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/python.png -------------------------------------------------------------------------------- /src/controls/images/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/screen.png -------------------------------------------------------------------------------- /src/table_tree/images/bao0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao0.png -------------------------------------------------------------------------------- /src/table_tree/images/bao1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao1.png -------------------------------------------------------------------------------- /src/table_tree/images/bao10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao10.png -------------------------------------------------------------------------------- /src/table_tree/images/bao11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao11.png -------------------------------------------------------------------------------- /src/table_tree/images/bao12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao12.png -------------------------------------------------------------------------------- /src/table_tree/images/bao13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao13.png -------------------------------------------------------------------------------- /src/table_tree/images/bao14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao14.png -------------------------------------------------------------------------------- /src/table_tree/images/bao2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao2.png -------------------------------------------------------------------------------- /src/table_tree/images/bao3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao3.png -------------------------------------------------------------------------------- /src/table_tree/images/bao4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao4.png -------------------------------------------------------------------------------- /src/table_tree/images/bao5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao5.png -------------------------------------------------------------------------------- /src/table_tree/images/bao6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao6.png -------------------------------------------------------------------------------- /src/table_tree/images/bao7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao7.png -------------------------------------------------------------------------------- /src/table_tree/images/bao8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao8.png -------------------------------------------------------------------------------- /src/table_tree/images/bao9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/bao9.png -------------------------------------------------------------------------------- /src/table_tree/images/flower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/flower.png -------------------------------------------------------------------------------- /src/table_tree/images/hammer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/hammer.png -------------------------------------------------------------------------------- /src/table_tree/images/music.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/music.png -------------------------------------------------------------------------------- /src/table_tree/images/root.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/root.png -------------------------------------------------------------------------------- /src/windows/images/addhover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/addhover.png -------------------------------------------------------------------------------- /src/windows/images/cartoon1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/cartoon1.ico -------------------------------------------------------------------------------- /src/windows/images/cartoon2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/cartoon2.ico -------------------------------------------------------------------------------- /src/windows/images/cartoon3.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/cartoon3.ico -------------------------------------------------------------------------------- /src/windows/images/cartoon4.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/cartoon4.ico -------------------------------------------------------------------------------- /src/windows/images/dropdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/dropdown.png -------------------------------------------------------------------------------- /src/windows/images/leftHover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/leftHover.png -------------------------------------------------------------------------------- /src/windows/images/leftdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/leftdown.png -------------------------------------------------------------------------------- /src/windows/images/leftdown2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/leftdown2.png -------------------------------------------------------------------------------- /src/windows/images/leftdown3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/leftdown3.png -------------------------------------------------------------------------------- /src/windows/images/leftup2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/leftup2.png -------------------------------------------------------------------------------- /src/windows/images/leftup3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/leftup3.png -------------------------------------------------------------------------------- /src/windows/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/loading.gif -------------------------------------------------------------------------------- /src/windows/images/rightdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/rightdown.png -------------------------------------------------------------------------------- /src/windows/images/rightup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/rightup.png -------------------------------------------------------------------------------- /src/windows/images/rightup2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/rightup2.png -------------------------------------------------------------------------------- /src/windows/images/rightup3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/rightup3.png -------------------------------------------------------------------------------- /src/windows/images/screen1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/screen1.jpg -------------------------------------------------------------------------------- /src/windows/images/screen2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/screen2.jpg -------------------------------------------------------------------------------- /src/basic/开发第一个基于PyQt5的桌面应用.txt: -------------------------------------------------------------------------------- 1 | 开发第一个基于PyQt5的桌面应用 2 | 3 | 4 | 必须使用两个类:QApplication和QWidget。都在PyQt5.QtWidgets。 5 | -------------------------------------------------------------------------------- /src/controls/images/Game Board.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Game Board.ico -------------------------------------------------------------------------------- /src/controls/images/Manticore.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Manticore.ico -------------------------------------------------------------------------------- /src/controls/images/Sorceress.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Sorceress.ico -------------------------------------------------------------------------------- /src/table_tree/images/cartoon1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/table_tree/images/cartoon1.ico -------------------------------------------------------------------------------- /src/windows/images/Cloudy_72px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/Cloudy_72px.png -------------------------------------------------------------------------------- /src/windows/images/leftPressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/leftPressed.png -------------------------------------------------------------------------------- /src/windows/images/rightdown2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/rightdown2.png -------------------------------------------------------------------------------- /src/windows/images/rightdown3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/rightdown3.png -------------------------------------------------------------------------------- /src/windows/images/square_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/images/square_add.png -------------------------------------------------------------------------------- /documents/01-初识PyQt5-01-PyQt5简介.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/documents/01-初识PyQt5-01-PyQt5简介.pptx -------------------------------------------------------------------------------- /src/controls/images/Air Elemental.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Air Elemental.ico -------------------------------------------------------------------------------- /src/controls/images/Shapeshifter.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Shapeshifter.ico -------------------------------------------------------------------------------- /src/controls/images/ajax-loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/ajax-loading.gif -------------------------------------------------------------------------------- /src/controls/images/Earth Elemental.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Earth Elemental.ico -------------------------------------------------------------------------------- /src/controls/images/Fire Elemental.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Fire Elemental.ico -------------------------------------------------------------------------------- /src/controls/images/Water Elemental.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Water Elemental.ico -------------------------------------------------------------------------------- /src/controls/images/Power Point (Dark).ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Power Point (Dark).ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Logo.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/doc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/doc.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/new.png -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/open.png -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/save.png -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/win.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/win.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/example/ui/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | This package contains the qt designer files and ui scripts. 3 | """ -------------------------------------------------------------------------------- /src/windows/屏幕快照 2018-12-09 上午10.19.22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/屏幕快照 2018-12-09 上午10.19.22.png -------------------------------------------------------------------------------- /src/controls/images/Power Point (Light).ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/controls/images/Power Point (Light).ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Archer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Archer.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Djinni.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Djinni.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Dragon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Dragon.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Goblin.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Goblin.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Golem.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Golem.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Knight.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Knight.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Troll.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Troll.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Wizard.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Wizard.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/close.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/close.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/python.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/python.jpg -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/python.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/python.png -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/screen.png -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Banshee.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Banshee.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Basilisk.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Basilisk.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Manticore.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Manticore.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Phoenix.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Phoenix.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Sorceress.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Sorceress.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Unicorn.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Unicorn.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Valkyrie.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Valkyrie.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/printer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/printer.png -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Game Board.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Game Board.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Air Elemental.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Air Elemental.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Fire Elemental.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Fire Elemental.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Shapeshifter.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Shapeshifter.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/ajax-loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/ajax-loading.gif -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Earth Elemental.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Earth Elemental.ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Water Elemental.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Water Elemental.ico -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/screenshots/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/screenshots/01.png -------------------------------------------------------------------------------- /src/designer/将.ui文件转换为.py文件.txt: -------------------------------------------------------------------------------- 1 | 将.ui文件转换为.py文件 2 | 3 | 方法一: 4 | 5 | python -m PyQt5.uic.pyuic demo.ui -o demo.py 6 | 7 | 方法二: 8 | 9 | pyuic5 demo.ui -o demo.py -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Power Point (Dark).ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Power Point (Dark).ico -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/images/Power Point (Light).ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/menu_toolbar_statusbar/images/Power Point (Light).ico -------------------------------------------------------------------------------- /src/windows/CommonHelper.py: -------------------------------------------------------------------------------- 1 | class CommonHelper: 2 | @staticmethod 3 | def readQSS(style): 4 | with open(style,'r') as f: 5 | return f.read() -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/close.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/undock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/undock.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/sizegrip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/sizegrip.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/up_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/up_arrow.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/branch_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/branch_open.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/close-hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/close-hover.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/down_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/down_arrow.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/left_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/left_arrow.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/right_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/right_arrow.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/transparent.png -------------------------------------------------------------------------------- /src/ext/pyinstaller.txt: -------------------------------------------------------------------------------- 1 | 使用Pyinstaller打包PyQt5应用 2 | 3 | 4 | pip3 install pyinstaller 5 | 6 | pyinstaller -Fw Calc.py 7 | 8 | -w:不显示终端 9 | -F:将所有的库打包成一个单独的文件 10 | 11 | -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/Hmovetoolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/Hmovetoolbar.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/Hsepartoolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/Hsepartoolbar.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/Vmovetoolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/Vmovetoolbar.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/Vsepartoolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/Vsepartoolbar.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/branch_closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/branch_closed.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/branch_open-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/branch_open-on.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/close-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/close-pressed.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/radio_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/radio_checked.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/branch_closed-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/branch_closed-on.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_checked.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/radio_unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/radio_unchecked.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/stylesheet-vline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/stylesheet-vline.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_unchecked.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/down_arrow_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/down_arrow_disabled.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/left_arrow_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/left_arrow_disabled.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/radio_checked_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/radio_checked_focus.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/up_arrow_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/up_arrow_disabled.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/screenshots/QDarkStyle example 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/screenshots/QDarkStyle example 1.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/screenshots/QDarkStyle example 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/screenshots/QDarkStyle example 2.png -------------------------------------------------------------------------------- /src/windows/style.qss: -------------------------------------------------------------------------------- 1 | QMainWindow{ 2 | border-image:url(./images/python.jpg); 3 | } 4 | 5 | QToolTip { 6 | border:1px solid rgb(45,45,45); 7 | background:white; 8 | color:red 9 | } -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/radio_unchecked_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/radio_unchecked_focus.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/right_arrow_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/right_arrow_disabled.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/stylesheet-branch-end.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/stylesheet-branch-end.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_checked_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_checked_focus.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_indeterminate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_indeterminate.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_unchecked_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_unchecked_focus.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/radio_checked_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/radio_checked_disabled.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/radio_unchecked_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/radio_unchecked_disabled.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/stylesheet-branch-more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/stylesheet-branch-more.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_checked_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_checked_disabled.png -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_indeterminate_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_indeterminate_focus.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_unchecked_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_unchecked_disabled.png -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_indeterminate_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekori/pyqt5/HEAD/src/windows/QDarkStyleSheet-master/qdarkstyle/rc/checkbox_indeterminate_disabled.png -------------------------------------------------------------------------------- /src/controls/主窗口类型.txt: -------------------------------------------------------------------------------- 1 | 主窗口类型 2 | 3 | 有3种窗口 4 | 5 | QMainWindow 6 | 7 | QWidget 8 | 9 | QDialog 10 | 11 | QMainWindow:可以包含菜单栏、工具栏、状态栏和标题栏,是最常见的窗口形式 12 | 13 | QDialog:是对话窗口的基类。没有菜单栏、工具栏、状态栏。 14 | 15 | QWidget:不确定窗口的用途,就使用QWidget。 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/web/factorial.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import * 2 | class Factorial(QObject): 3 | @pyqtSlot(int, result=int) 4 | def factorial(self,n): 5 | if n == 0 or n == 1: 6 | return 1 7 | else: 8 | return self.factorial(n - 1) * n 9 | 10 | -------------------------------------------------------------------------------- /src/web/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 测试页面 6 | 7 | 8 |

Hello PyQt5

9 |

Hello PyQt5

10 |

Hello PyQt5

11 |

Hello PyQt5

12 | 13 | -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/example/ui/compile_ui.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Compile example.ui for PyQt and PySide. 3 | pyuic4 --from-imports example.ui > example_pyqt_ui.py 4 | pyuic5 --from-imports example.ui > example_pyqt5_ui.py 5 | pyside-uic --from-imports example.ui > example_pyside_ui.py 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/basic/搭建PyQt5开发环境.txt: -------------------------------------------------------------------------------- 1 | 搭建PyQt5开发环境 2 | 3 | ok 1. Python 4 | 5 | Anaconda 6 | 7 | 2. PyQt5模块 8 | 9 | pip install pyqt5 10 | 11 | pip uninstall pyqt5 12 | 13 | 如果本机安装了多个Python环境,要分清pip到底属于哪一个Python环境 14 | 15 | 在Python的REPL环境中输入import PyQt5,如果没有报错,说明PyQt5安装成功 16 | 17 | 3. PyCharm 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/MANIFEST.in: -------------------------------------------------------------------------------- 1 | # 2 | # MANIFEST.in 3 | # 4 | # Manifest template for creating the PyLudic source distribution. 5 | 6 | include MANIFEST.in 7 | include setup.py 8 | include COPYING 9 | include README.md 10 | include qdarkstyle/style.qss 11 | include qdarkstyle/style.qrc 12 | include qdarkstyle/rc/*.png 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/designer/RunMainWinBuddy.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinBuddy 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinBuddy.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/RunMainWinTabOrder.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinTabOrder 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinTabOrder.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/RunMainWinVHLayout.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinVHLayout 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinVHLayout.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/RunMainWinFormLayout.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinFormLayout 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinFormLayout.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/RunMainWinGridLayout.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinGridLayout 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinGridLayout.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/RunMainWinSignalSlot.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinSignalSlot 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinSignalSlot.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/RunMainWinSizePolicy.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinSizePolicy 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinSizePolicy.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/RunMainWinSpacerLine.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinSpacerLine 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinSpacerLine.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/在Qt Designer中设置信号与槽.txt: -------------------------------------------------------------------------------- 1 | 在Qt Designer中设置信号与槽 2 | 3 | 信号(signal) 4 | 槽(slot) 5 | 6 | 是Qt的核心机制,也是PyQt的核心机制 7 | 8 | 信号:是由对象或控件发射出去的消息。 9 | 10 | 按钮的单击事件 11 | 12 | 当单击按钮时,按钮就会向外部发送单击的消息,这些发送出去的信号需要一些代码来拦截,这些代码就是槽 13 | 14 | 槽本质上是一个函数或方法 15 | 16 | 信号可以理解为事件 17 | 18 | 槽可以理解为事件函数 19 | 20 | 21 | 需要将信号和槽绑定 22 | 23 | 一个信号可以和多个槽绑定, 一个槽可以拦截多个信号 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/designer/RunMainWinMenuToolbar.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinMenuToolbar 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinMenuToolbar.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/RunMainWinAbsoluteLayout.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinAbsoluteLayout 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinAbsoluteLayout.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/RunMainWinVerticalLayout.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinVerticalLayout 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinVerticalLayout.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/RunMainWinContainerLayout.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinContainerLayout 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinContainerLayout.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/RunMainWinHorizontalLayout.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import MainWinHorizontalLayout 3 | from PyQt5.QtWidgets import QApplication,QMainWindow 4 | 5 | if __name__ == '__main__': 6 | app = QApplication(sys.argv) 7 | mainWindow = QMainWindow() 8 | ui = MainWinHorizontalLayout.Ui_MainWindow() 9 | # 向主窗口上添加控件 10 | ui.setupUi(mainWindow) 11 | mainWindow.show() 12 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | /style.rcc 3 | /style_pyside_rc.py 4 | ./.idea 5 | /.idea/ 6 | /dist/ 7 | /QDarkStyle.egg-info/ 8 | /build/ 9 | __pycache__ 10 | *.tar 11 | *.tar.* 12 | *.log 13 | *.log.* 14 | *.sig 15 | pkg/ 16 | src/ 17 | 18 | # stdeb files 19 | *.tar.gz 20 | deb_dist 21 | /gpg_key 22 | 23 | # gedit temp files 24 | *~ 25 | 26 | # hackedit project files 27 | .hackedit 28 | 29 | -------------------------------------------------------------------------------- /src/windows/OpacityWindow.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 创建透明窗口 4 | 5 | ''' 6 | 7 | from PyQt5.Qt import * 8 | import sys 9 | 10 | if __name__ == "__main__": 11 | app = QApplication(sys.argv) 12 | win = QMainWindow() 13 | win.setWindowTitle('窗口的透明度设置') 14 | # 0到1,1表示不透明,0表示完全透明 15 | win.setWindowOpacity(0.6) 16 | 17 | button = QPushButton('我的按钮',win) 18 | 19 | win.resize(400,200) 20 | win.show() 21 | sys.exit(app.exec()) -------------------------------------------------------------------------------- /src/designer/尺寸策略.txt: -------------------------------------------------------------------------------- 1 | 尺寸策略(sizePolicy) 2 | 3 | sizeHint(期望尺寸) 4 | 5 | 对于大多数控件来说,sizeHint的值是只读的 6 | 7 | 读取期望尺寸 8 | 9 | self.pushButton.sizeHint().width() // 77 10 | self.pushButton.sizeHint().height() // 32 11 | 12 | QPushButton width:77 height 32 13 | QTextEdit width:256 height:192 14 | 15 | 最小期望尺寸 16 | 17 | self.pushButton.minimumSizeHint().width() 18 | self.pushButton.minimumSizeHint().height() 19 | 20 | QTextEdit 78 78 21 | 22 | QPushButton的期望尺寸和最新期望尺寸相同 23 | 24 | -------------------------------------------------------------------------------- /src/basic/First.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from PyQt5.QtWidgets import QApplication,QWidget 4 | 5 | if __name__ == '__main__': 6 | # 创建QApplication类的实例 7 | app = QApplication(sys.argv) 8 | # 创建一个窗口 9 | w = QWidget() 10 | # 设置窗口的尺寸 11 | w.resize(400,200) 12 | # 移动窗口 13 | w.move(300,300) 14 | 15 | # 设置窗口的标题 16 | w.setWindowTitle('第一个基于PyQt5的桌面应用') 17 | # 显示窗口 18 | w.show() 19 | 20 | # 进入程序的主循环、并通过exit函数确保主循环安全结束 21 | sys.exit(app.exec_()) 22 | -------------------------------------------------------------------------------- /src/project/getWeatherInfo.py: -------------------------------------------------------------------------------- 1 | 2 | import requests 3 | 4 | rep = requests.get('http://www.weather.com.cn/data/sk/101010100.html') 5 | rep.encoding = 'utf-8' 6 | 7 | print('返回结果: %s' % rep.json() ) 8 | print('城市: %s' % rep.json()['weatherinfo']['city'] ) 9 | print('风向: %s' % rep.json()['weatherinfo']['WD'] ) 10 | print('温度: %s' % rep.json()['weatherinfo']['temp'] + " 度") 11 | print('风力: %s' % rep.json()['weatherinfo']['WS'] ) 12 | print('湿度: %s' % rep.json()['weatherinfo']['SD'] ) 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/web/MySharedObject.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from PyQt5.QtCore import * 4 | 5 | from PyQt5.QtWidgets import QWidget,QMessageBox 6 | 7 | class MySharedObject(QObject): 8 | 9 | @pyqtSlot(int,int,result=int,name="addInt") 10 | def addInt(self,a,b): 11 | print(b) 12 | return a+b 13 | def getStrValue( self): 14 | return '123' 15 | 16 | def setStrValue( self, str ): 17 | # 18 | print('获得页面参数 :%s'% str ) 19 | 20 | #需要定义对外发布的方法 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/multithread/AutoCloseWindow.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 让程序定时关闭 4 | 5 | QTimer.singleShot 6 | 7 | ''' 8 | 9 | import sys 10 | from PyQt5.QtWidgets import * 11 | from PyQt5.QtGui import * 12 | from PyQt5.QtCore import * 13 | 14 | if __name__ == '__main__': 15 | app = QApplication(sys.argv) 16 | label = QLabel('Hello World,窗口在5秒后自动关闭!') 17 | label.setWindowFlags(Qt.SplashScreen | Qt.FramelessWindowHint) 18 | label.show() 19 | QTimer.singleShot(5000,app.quit) 20 | 21 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.7" 4 | - "3.2" 5 | virtualenv: 6 | system_site_packages: true 7 | before_install: 8 | - sudo apt-get update 9 | - sudo apt-get install -qq python-pyside --fix-missing 10 | - sudo apt-get install -qq python-qt4 --fix-missing 11 | - sudo apt-get install -qq python3-pyside --fix-missing 12 | - sudo apt-get install -qq python3-pyqt4 --fix-missing 13 | - "export DISPLAY=:99.0" 14 | - "sh -e /etc/init.d/xvfb start" 15 | before_script: 16 | - cd example 17 | script: 18 | - python example_pyqt.py --travis 19 | - python example_pyside.py --travis 20 | -------------------------------------------------------------------------------- /src/SignalSlot/OverrideSlot.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | Override(覆盖)槽函数 4 | 5 | ''' 6 | 7 | from PyQt5.QtWidgets import * 8 | from PyQt5.QtCore import * 9 | import sys 10 | 11 | class OverrideSlot(QWidget): 12 | def __init__(self): 13 | super().__init__() 14 | self.setWindowTitle("Override(覆盖)槽函数") 15 | def keyPressEvent(self, e): 16 | if e.key() == Qt.Key_Escape: 17 | self.close() 18 | elif e.key() == Qt.Key_Alt: 19 | self.setWindowTitle("按下Alt键") 20 | 21 | 22 | 23 | if __name__ == "__main__": 24 | app = QApplication(sys.argv) 25 | form = OverrideSlot() 26 | form.show() 27 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/Background1.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 使用多种方式设置窗口背景色和背景图片 4 | 5 | 1. QSS 6 | 2. QPalette 7 | 3. 直接绘制 8 | 9 | ''' 10 | 11 | import sys 12 | from PyQt5.QtWidgets import * 13 | from PyQt5.QtGui import * 14 | from PyQt5.QtCore import * 15 | 16 | class Background1(QWidget): 17 | def __init__(self): 18 | super().__init__() 19 | self.setWindowTitle("绘制背景颜色") 20 | def paintEvent(self, event): 21 | painter = QPainter(self) 22 | painter.setBrush(Qt.yellow) 23 | painter.drawRect(self.rect()) 24 | if __name__ == "__main__": 25 | app = QApplication(sys.argv) 26 | form = Background1() 27 | 28 | form.show() 29 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/controls/FirstMainWin.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QMainWindow,QApplication 3 | from PyQt5.QtGui import QIcon 4 | 5 | class FirstMainWin(QMainWindow): 6 | def __init__(self): 7 | super(FirstMainWin,self).__init__() 8 | 9 | # 设置主窗口的标题 10 | self.setWindowTitle('第一个主窗口应用') 11 | 12 | # 设置窗口的尺寸 13 | self.resize(400,300) 14 | 15 | self.status = self.statusBar() 16 | 17 | self.status.showMessage('只存在5秒的消息',5000) 18 | 19 | if __name__ == '__main__': 20 | app = QApplication(sys.argv) 21 | 22 | app.setWindowIcon(QIcon('./images/Dragon.ico')) 23 | main = FirstMainWin() 24 | main.show() 25 | 26 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/ext/MyDB.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 操作SQLite数据库 4 | 5 | ''' 6 | 7 | import sys 8 | 9 | from PyQt5.QtSql import QSqlDatabase,QSqlQuery 10 | 11 | def createDB(): 12 | db = QSqlDatabase.addDatabase('QSQLITE') 13 | # 指定SQLite数据库的文件名 14 | db.setDatabaseName('./db/database.db') 15 | if not db.open(): 16 | print('无法建立与数据库的连接') 17 | return False 18 | query = QSqlQuery() 19 | query.exec('create table people(id int primary key,name varchar(10),address varchar(50))') 20 | query.exec('insert into people values(1,"李宁","Shenyang")') 21 | query.exec('insert into people values(2,"超人","克星")') 22 | db.close() 23 | return True 24 | 25 | if __name__ == '__main__': 26 | createDB() -------------------------------------------------------------------------------- /src/windows/Background2.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 使用多种方式设置窗口背景色和背景图片 4 | 5 | 1. QSS 6 | 2. QPalette 7 | 3. 直接绘制 8 | 9 | ''' 10 | 11 | import sys 12 | from PyQt5.QtWidgets import * 13 | from PyQt5.QtGui import * 14 | from PyQt5.QtCore import * 15 | 16 | class Background2(QWidget): 17 | def __init__(self): 18 | super().__init__() 19 | self.setWindowTitle("绘制背景图片") 20 | def paintEvent(self, event): 21 | painter = QPainter(self) 22 | pixmap = QPixmap('./images/screen1.jpg') 23 | 24 | painter.drawPixmap(self.rect(),pixmap) 25 | if __name__ == "__main__": 26 | app = QApplication(sys.argv) 27 | form = Background2() 28 | 29 | form.show() 30 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/layout/AbsoluteLayout.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 绝对布局 3 | 4 | ''' 5 | 6 | 7 | import sys,math 8 | from PyQt5.QtWidgets import * 9 | 10 | 11 | class AbsoluteLayout(QWidget) : 12 | def __init__(self): 13 | super(AbsoluteLayout,self).__init__() 14 | self.setWindowTitle("绝对布局") 15 | 16 | self.label1 = QLabel('欢迎',self) 17 | self.label1.move(15,20) 18 | 19 | self.label2 = QLabel('学习',self) 20 | self.label2.move(35,40) 21 | 22 | self.label3 = QLabel('PyQt5',self) 23 | self.label3.move(55,80) 24 | 25 | 26 | 27 | 28 | 29 | if __name__ == '__main__': 30 | app = QApplication(sys.argv) 31 | main = AbsoluteLayout() 32 | main.show() 33 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/WindowPattern.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 设置窗口样式(主要是窗口边框、标题栏以及窗口本身的样式) 4 | 5 | ''' 6 | 7 | from PyQt5.QtCore import * 8 | import sys 9 | from PyQt5.QtWidgets import * 10 | 11 | class WindowPattern(QMainWindow): 12 | def __init__(self): 13 | super().__init__() 14 | self.resize(500,260) 15 | self.setWindowTitle('设置窗口的样式') 16 | 17 | self.setWindowFlags(Qt.WindowMaximizeButtonHint | Qt.WindowStaysOnTopHint ) 18 | self.setObjectName("MainWindow") 19 | self.setStyleSheet("#MainWindow{border-image:url(images/python.jpg);}") 20 | 21 | if __name__ == "__main__": 22 | app = QApplication(sys.argv) 23 | form = WindowPattern() 24 | form.show() 25 | sys.exit(app.exec_()) 26 | -------------------------------------------------------------------------------- /src/windows/gitanim.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 装载Gif动画 4 | 5 | QMovie 6 | ''' 7 | 8 | import sys 9 | from PyQt5.QtWidgets import QApplication, QLabel ,QWidget 10 | from PyQt5.QtCore import Qt 11 | from PyQt5.QtGui import QMovie 12 | 13 | class LoadingGif(QWidget): 14 | def __init__(self): 15 | super().__init__() 16 | self.label = QLabel("",self) 17 | self.setFixedSize(128,128) 18 | self.setWindowFlags(Qt.Dialog | Qt.CustomizeWindowHint) 19 | self.movie = QMovie('./images/loading.gif') 20 | self.label.setMovie(self.movie) 21 | self.movie.start() 22 | 23 | if __name__ == "__main__": 24 | app = QApplication(sys.argv) 25 | form = LoadingGif() 26 | form.show() 27 | sys.exit(app.exec_()) 28 | 29 | -------------------------------------------------------------------------------- /src/layout/VBoxLayout.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 垂直盒布局(QBoxLayout) 4 | 5 | 6 | 7 | ''' 8 | 9 | import sys,math 10 | from PyQt5.QtWidgets import * 11 | 12 | 13 | class VBoxLayout(QWidget) : 14 | def __init__(self): 15 | super(VBoxLayout,self).__init__() 16 | self.setWindowTitle("垂直盒布局") 17 | 18 | layout = QVBoxLayout() 19 | layout.addWidget(QPushButton('按钮1')) 20 | layout.addWidget(QPushButton('按钮2')) 21 | layout.addWidget(QPushButton('按钮3')) 22 | layout.addWidget(QPushButton('按钮4')) 23 | layout.addWidget(QPushButton('按钮5')) 24 | 25 | self.setLayout(layout) 26 | 27 | 28 | 29 | 30 | 31 | 32 | if __name__ == '__main__': 33 | app = QApplication(sys.argv) 34 | main = VBoxLayout() 35 | main.show() 36 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/SignalSlot/SignalSlotDemo.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 信号(Signal)与槽(Slot) 4 | 5 | ''' 6 | from PyQt5.QtWidgets import * 7 | import sys 8 | 9 | class SigalSlotDemo(QWidget): 10 | def __init__(self): 11 | super(SigalSlotDemo,self).__init__() 12 | self.initUI() 13 | 14 | def onClick(self): 15 | self.btn.setText("信号已经发出") 16 | self.btn.setStyleSheet("QPushButton(max-width:200px;min-width:200px") 17 | 18 | def initUI(self): 19 | self.setGeometry(300, 300, 500, 400) 20 | self.setWindowTitle('信号(Signal)与槽(Slot)') 21 | self.btn = QPushButton('我的按钮',self) 22 | self.btn.clicked.connect(self.onClick) 23 | 24 | 25 | 26 | if __name__ == '__main__': 27 | app = QApplication(sys.argv) 28 | gui = SigalSlotDemo() 29 | gui.show() 30 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/web/LocalHTML.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 装载本地Web页面 4 | 5 | ''' 6 | 7 | from PyQt5.QtCore import * 8 | from PyQt5.QtGui import * 9 | from PyQt5.QtWidgets import * 10 | from PyQt5.QtWebEngineWidgets import * 11 | import sys 12 | import os 13 | class WebEngineView(QMainWindow): 14 | 15 | def __init__(self ): 16 | super(WebEngineView, self).__init__() 17 | self.setWindowTitle('装载本地Web页面') 18 | self.setGeometry(5, 30, 1355, 730) 19 | url = os.getcwd() + '/test.html' 20 | self.browser = QWebEngineView() 21 | self.browser.load(QUrl.fromLocalFile(url)) 22 | 23 | self.setCentralWidget(self.browser) 24 | 25 | 26 | print(os.getcwd()) 27 | if __name__ == '__main__': 28 | app = QApplication(sys.argv) 29 | win = WebEngineView() 30 | win.show() 31 | sys.exit(app.exec_()) 32 | -------------------------------------------------------------------------------- /src/SignalSlot/WinSignal.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 为窗口类添加信号 4 | 5 | ''' 6 | from PyQt5.QtWidgets import * 7 | from PyQt5.QtCore import * 8 | import sys 9 | 10 | class WinSignal(QWidget): 11 | button_clicked_signal = pyqtSignal() 12 | 13 | def __init__(self): 14 | super().__init__() 15 | self.setWindowTitle("为窗口类添加信号") 16 | self.resize(300,100) 17 | 18 | 19 | btn = QPushButton('关闭窗口',self) 20 | 21 | btn.clicked.connect(self.btn_clicked) 22 | 23 | self.button_clicked_signal.connect(self.btn_close) 24 | 25 | def btn_clicked(self): 26 | self.button_clicked_signal.emit() 27 | 28 | def btn_close(self): 29 | self.close() 30 | if __name__ == '__main__': 31 | app = QApplication(sys.argv) 32 | example = WinSignal() 33 | example.show() 34 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/layout/HBoxLayout.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 水平盒布局(QHBoxLayout) 4 | 5 | 6 | 7 | ''' 8 | 9 | import sys,math 10 | from PyQt5.QtWidgets import * 11 | 12 | 13 | class HBoxLayout(QWidget) : 14 | def __init__(self): 15 | super(HBoxLayout,self).__init__() 16 | self.setWindowTitle("水平盒布局") 17 | 18 | hlayout = QHBoxLayout() 19 | hlayout.addWidget(QPushButton('按钮1')) 20 | hlayout.addWidget(QPushButton('按钮2')) 21 | hlayout.addWidget(QPushButton('按钮3')) 22 | hlayout.addWidget(QPushButton('按钮4')) 23 | hlayout.addWidget(QPushButton('按钮5')) 24 | hlayout.setSpacing(40) 25 | self.setLayout(hlayout) 26 | 27 | 28 | 29 | 30 | 31 | 32 | if __name__ == '__main__': 33 | app = QApplication(sys.argv) 34 | main = HBoxLayout() 35 | main.show() 36 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/Background.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 使用多种方式设置窗口背景色和背景图片 4 | 5 | 1. QSS 6 | 2. QPalette 7 | 3. 直接绘制 8 | 9 | ''' 10 | 11 | import sys 12 | from PyQt5.QtWidgets import * 13 | from PyQt5.QtGui import * 14 | from PyQt5.QtCore import * 15 | 16 | app = QApplication(sys.argv) 17 | win = QMainWindow() 18 | win.setWindowTitle("背景图片") 19 | win.resize(350,250) 20 | win.setObjectName("MainWindow") 21 | ''' 22 | # 通过QSS动态修改窗口的背景颜色和背景图片 23 | #win.setStyleSheet("#MainWindow{border-image:url(./images/python.jpg);}") 24 | win.setStyleSheet("#MainWindow{background-color:yellow}") 25 | ''' 26 | 27 | # 通过QPalette设置背景图片和背景颜色 28 | #palette = QPalette() 29 | #palette.setBrush(QPalette.Background,QBrush(QPixmap("./images/python.jpg"))) 30 | #palette.setColor(QPalette.Background,Qt.red) 31 | #win.setPalette(palette) 32 | 33 | win.show() 34 | sys.exit(app.exec()) 35 | 36 | -------------------------------------------------------------------------------- /src/web/WebEngineView.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 用Web浏览器控件(QWebEngineView)显示网页 4 | 5 | PyQt5和Web的交互技术 6 | 7 | 同时使用Python和Web开发程序,混合开发 8 | 9 | Python+JavaScript+HTML5+CSS 10 | 11 | QWebEngineView 12 | 13 | ''' 14 | 15 | from PyQt5.QtCore import * 16 | from PyQt5.QtGui import * 17 | from PyQt5.QtWidgets import * 18 | from PyQt5.QtWebEngineWidgets import * 19 | import sys 20 | 21 | class WebEngineView(QMainWindow): 22 | 23 | def __init__(self ): 24 | super(WebEngineView, self).__init__() 25 | self.setWindowTitle('打开外部网页例子') 26 | self.setGeometry(5, 30, 1355, 730) 27 | self.browser = QWebEngineView() 28 | self.browser.load(QUrl('https://www.jd.com')) 29 | self.setCentralWidget(self.browser) 30 | 31 | 32 | if __name__ == '__main__': 33 | app = QApplication(sys.argv) 34 | win = WebEngineView() 35 | win.show() 36 | sys.exit(app.exec_()) 37 | -------------------------------------------------------------------------------- /src/controls/IconForm.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QMainWindow,QApplication 3 | from PyQt5.QtGui import QIcon 4 | ''' 5 | 窗口的setWindowIcon方法用于设置窗口的图标,只在Windows中可用 6 | 7 | QAplication中的setWindowIcon方法用于设置主窗口的图标和应用程序图标,但调用了窗口的setWindowIcon方法 8 | QAplication中的setWindowIcon方法就只能用于设置应用程序图标了 9 | ''' 10 | class IconForm(QMainWindow): 11 | def __init__(self): 12 | super(IconForm,self).__init__() 13 | self.initUI() 14 | 15 | def initUI(self): 16 | 17 | self.setGeometry(300,300,250,250) 18 | # 设置主窗口的标题 19 | self.setWindowTitle('设置窗口图标') 20 | # 设置窗口图标 21 | self.setWindowIcon(QIcon('./images/Basilisk.ico')) 22 | 23 | 24 | if __name__ == '__main__': 25 | app = QApplication(sys.argv) 26 | app.setWindowIcon(QIcon('./images/Dragon.ico')) 27 | main = IconForm() 28 | main.show() 29 | 30 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/QSSSubControl.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | QSS子控件选择器 4 | 5 | QComboBox 6 | 7 | ''' 8 | 9 | from PyQt5.QtWidgets import * 10 | import sys 11 | 12 | class QSSSubControl(QWidget): 13 | def __init__(self): 14 | super().__init__() 15 | self.setWindowTitle("QSS子控件选择器") 16 | combo = QComboBox(self) 17 | combo.setObjectName("myComboBox") 18 | combo.addItem("Window") 19 | combo.addItem("Linux") 20 | combo.addItem("Mac OS X") 21 | 22 | combo.move(50,50) 23 | 24 | self.setGeometry(250,200,320,150) 25 | if __name__ == "__main__": 26 | app = QApplication(sys.argv) 27 | form = QSSSubControl() 28 | qssStyle = ''' 29 | QComboBox#myComboBox::drop-down { 30 | image:url(./images/dropdown.png) 31 | } 32 | ''' 33 | form.setStyleSheet(qssStyle) 34 | form.show() 35 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/controls/CenterForm.py: -------------------------------------------------------------------------------- 1 | # QDesktopWidget 2 | import sys 3 | from PyQt5.QtWidgets import QDesktopWidget,QMainWindow,QApplication 4 | from PyQt5.QtGui import QIcon 5 | 6 | class CenterForm(QMainWindow): 7 | def __init__(self): 8 | super(CenterForm,self).__init__() 9 | 10 | # 设置主窗口的标题 11 | self.setWindowTitle('让窗口居中') 12 | 13 | # 设置窗口的尺寸 14 | self.resize(400,300) 15 | 16 | def center(self): 17 | # 获取屏幕坐标系 18 | screen = QDesktopWidget().screenGeometry() 19 | # 获取窗口坐标系 20 | size = self.geometry() 21 | newLeft = (screen.width() - size.width()) / 2 22 | newTop = (screen.height() - size.height()) / 2 23 | self.move(newLeft,newTop) 24 | 25 | 26 | if __name__ == '__main__': 27 | app = QApplication(sys.argv) 28 | main = CenterForm() 29 | main.show() 30 | 31 | sys.exit(app.exec_()) 32 | -------------------------------------------------------------------------------- /src/SignalSlot/CustomSignal.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 自定义信号 4 | 5 | pyqtSignal() 6 | 7 | ''' 8 | 9 | from PyQt5.QtCore import * 10 | class MyTypeSignal(QObject): 11 | # 定义一个信号 12 | sendmsg = pyqtSignal(object) 13 | 14 | # 发送3个参数的信号 15 | sendmsg1 = pyqtSignal(str,int,int) 16 | 17 | def run(self): 18 | self.sendmsg.emit('Hello PyQt5') 19 | 20 | def run1(self): 21 | self.sendmsg1.emit("hello",3,4) 22 | 23 | 24 | class MySlot(QObject): 25 | def get(self,msg): 26 | print("信息:" + msg) 27 | def get1(self,msg,a,b): 28 | print(msg) 29 | print(a+b) 30 | 31 | 32 | if __name__ == '__main__': 33 | send = MyTypeSignal() 34 | slot = MySlot() 35 | 36 | send.sendmsg.connect(slot.get) 37 | send.sendmsg1.connect(slot.get1) 38 | 39 | 40 | send.run() 41 | send.run1() 42 | 43 | send.sendmsg.disconnect(slot.get) 44 | send.run() -------------------------------------------------------------------------------- /src/layout/FormLayout.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 表单布局(QFormLayout) 4 | 5 | ''' 6 | 7 | import sys,math 8 | from PyQt5.QtWidgets import * 9 | 10 | 11 | class FormForm(QWidget) : 12 | def __init__(self): 13 | super(FormForm,self).__init__() 14 | self.setWindowTitle("表单布局") 15 | self.resize(350,300) 16 | 17 | formLayout = QFormLayout() 18 | 19 | titleLabel = QLabel('标题') 20 | authorLabel = QLabel('作者') 21 | contentLabel = QLabel('内容') 22 | 23 | titleEdit = QLineEdit() 24 | authorEdit = QLineEdit() 25 | contentEdit = QTextEdit() 26 | 27 | formLayout.addRow(titleLabel,titleEdit) 28 | formLayout.addRow(authorLabel,authorEdit) 29 | formLayout.addRow(contentLabel,contentEdit) 30 | 31 | self.setLayout(formLayout) 32 | 33 | 34 | 35 | if __name__ == '__main__': 36 | app = QApplication(sys.argv) 37 | main = FormForm() 38 | main.show() 39 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/layout/Stretch.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 设置伸缩量(addStretch) 4 | 5 | 6 | 7 | ''' 8 | 9 | import sys,math 10 | from PyQt5.QtWidgets import * 11 | 12 | 13 | class Stretch(QWidget) : 14 | def __init__(self): 15 | super(Stretch,self).__init__() 16 | self.setWindowTitle("设置伸缩量") 17 | btn1 = QPushButton(self) 18 | btn2 = QPushButton(self) 19 | btn3 = QPushButton(self) 20 | btn1.setText("按钮1") 21 | btn2.setText("按钮2") 22 | btn3.setText("按钮3") 23 | 24 | layout = QHBoxLayout() 25 | 26 | layout.addStretch(1) 27 | layout.addWidget(btn1) 28 | 29 | layout.addStretch(2) 30 | layout.addWidget(btn2) 31 | layout.addStretch(3) 32 | layout.addWidget(btn3) 33 | 34 | self.setLayout(layout) 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | if __name__ == '__main__': 43 | app = QApplication(sys.argv) 44 | main = Stretch() 45 | main.show() 46 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/table_tree/ListWidget.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 扩展的列表控件(QListWidget) 4 | 5 | QListView 6 | ''' 7 | from PyQt5.QtWidgets import * 8 | import sys 9 | 10 | class ListWidgetDemo(QMainWindow): 11 | def __init__(self, parent=None): 12 | super(ListWidgetDemo, self).__init__(parent) 13 | self.setWindowTitle("QListWidget 例子") 14 | self.resize(300, 270) 15 | self.listwidget = QListWidget() 16 | self.listwidget.addItem("item1") 17 | self.listwidget.addItem("item2") 18 | self.listwidget.addItem("item3") 19 | self.listwidget.addItem("item4") 20 | self.listwidget.addItem("item5") 21 | self.listwidget.itemClicked.connect(self.clicked) 22 | self.setCentralWidget(self.listwidget) 23 | def clicked(self,Index): 24 | QMessageBox.information(self,"QListWidget","您选择了:" + self.listwidget.item(self.listwidget.row(Index)).text()) 25 | 26 | 27 | 28 | if __name__ == "__main__": 29 | app = QApplication(sys.argv) 30 | win = ListWidgetDemo() 31 | win.show() 32 | sys.exit(app.exec_()) 33 | -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/Menu.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 创建和使用菜单 4 | 5 | ''' 6 | 7 | import sys,math 8 | from PyQt5.QtWidgets import * 9 | from PyQt5.QtGui import * 10 | from PyQt5.QtCore import * 11 | 12 | class Menu(QMainWindow) : 13 | def __init__(self): 14 | super(Menu,self).__init__() 15 | bar = self.menuBar() # 获取菜单栏 16 | 17 | file = bar.addMenu("文件") 18 | file.addAction("新建") 19 | 20 | save = QAction("保存",self) 21 | save.setShortcut("Ctrl + S") 22 | file.addAction(save) 23 | 24 | save.triggered.connect(self.process) 25 | 26 | edit = bar.addMenu("Edit") 27 | edit.addAction("copy") 28 | edit.addAction("paste") 29 | quit = QAction("退出",self) 30 | file.addAction(quit) 31 | 32 | def process(self,a): 33 | print(self.sender().text()) 34 | 35 | 36 | if __name__ == '__main__': 37 | app = QApplication(sys.argv) 38 | main = Menu() 39 | main.show() 40 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/controls/Tooltip.py: -------------------------------------------------------------------------------- 1 | # 显示控件提示消息 2 | 3 | import sys 4 | from PyQt5.QtWidgets import QHBoxLayout,QMainWindow,QApplication,QToolTip,QPushButton,QWidget 5 | from PyQt5.QtGui import QFont 6 | 7 | class TooltipForm(QMainWindow): 8 | def __init__(self): 9 | super().__init__() 10 | self.initUI() 11 | 12 | def initUI(self): 13 | QToolTip.setFont(QFont('SansSerif',12)) 14 | self.setToolTip('今天是星期五') 15 | self.setGeometry(300,30,200,300) 16 | self.setWindowTitle('设置控件提示消息') 17 | 18 | 19 | self.button1 = QPushButton('我的按钮') 20 | self.button1.setToolTip('这是一个按钮,Are you ok?') 21 | layout = QHBoxLayout() 22 | layout.addWidget(self.button1) 23 | 24 | mainFrame = QWidget() 25 | mainFrame.setLayout(layout) 26 | self.setCentralWidget(mainFrame) 27 | 28 | if __name__ == '__main__': 29 | app = QApplication(sys.argv) 30 | main = TooltipForm() 31 | main.show() 32 | 33 | sys.exit(app.exec_()) 34 | -------------------------------------------------------------------------------- /src/drawing/DrawPoints.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 用像素点绘制正弦曲线 4 | 5 | -2PI 2PI 6 | 7 | drawPoint(x,y) 8 | 9 | ''' 10 | 11 | import sys,math 12 | from PyQt5.QtWidgets import * 13 | from PyQt5.QtGui import * 14 | from PyQt5.QtCore import Qt 15 | 16 | class DrawPoints(QWidget): 17 | def __init__(self): 18 | super(DrawPoints,self).__init__() 19 | self.resize(300,300) 20 | self.setWindowTitle('在窗口上用像素点绘制2个周期的正弦曲线') 21 | 22 | def paintEvent(self, event): 23 | painter = QPainter() 24 | painter.begin(self) 25 | painter.setPen(Qt.blue) 26 | size = self.size() 27 | 28 | for i in range(1000): 29 | x = 100 * (-1 + 2.0 * i/1000) + size.width()/2.0 30 | y = -50 * math.sin((x - size.width()/2.0) * math.pi/50) + size.height()/2.0 31 | painter.drawPoint(x,y) 32 | 33 | painter.end() 34 | if __name__ == '__main__': 35 | app = QApplication(sys.argv) 36 | main = DrawPoints() 37 | main.show() 38 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/BasicQSS.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | QSS基础 4 | 5 | QSS(Qt Style Sheets) 6 | Qt样式表 7 | 8 | 用于设置控件的样式 9 | 10 | CSS 11 | 12 | ''' 13 | 14 | from PyQt5.QtWidgets import * 15 | import sys 16 | class BasicQSS(QWidget): 17 | def __init__(self): 18 | super().__init__() 19 | self.setWindowTitle("QSS样式") 20 | btn1 = QPushButton(self) 21 | btn1.setText("按钮1") 22 | btn2 = QPushButton(self) 23 | btn2.setText("按钮2") 24 | 25 | btn3 = QPushButton(self) 26 | btn3.setText("按钮3") 27 | 28 | vbox = QVBoxLayout() 29 | vbox.addWidget(btn1) 30 | vbox.addWidget(btn2) 31 | vbox.addWidget(btn3) 32 | 33 | self.setLayout(vbox) 34 | if __name__ == "__main__": 35 | app = QApplication(sys.argv) 36 | form = BasicQSS() 37 | # 选择器 38 | qssStyle = ''' 39 | QPushButton { 40 | background-color:red 41 | } 42 | ''' 43 | form.setStyleSheet(qssStyle) 44 | form.show() 45 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/layout/HBoxLayoutAlign.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 设置控件的对齐方式 4 | 5 | 6 | 7 | ''' 8 | 9 | import sys,math 10 | from PyQt5.QtWidgets import * 11 | from PyQt5.QtCore import Qt 12 | 13 | 14 | class HBoxLayoutAlign(QWidget) : 15 | def __init__(self): 16 | super(HBoxLayoutAlign,self).__init__() 17 | self.setWindowTitle("水平盒布局") 18 | 19 | hlayout = QHBoxLayout() 20 | hlayout.addWidget(QPushButton('按钮1'),2,Qt.AlignLeft | Qt.AlignTop) 21 | hlayout.addWidget(QPushButton('按钮2'),4,Qt.AlignLeft | Qt.AlignTop) 22 | hlayout.addWidget(QPushButton('按钮3'),1,Qt.AlignLeft | Qt.AlignTop) 23 | hlayout.addWidget(QPushButton('按钮4'),1,Qt.AlignLeft | Qt.AlignBottom) 24 | hlayout.addWidget(QPushButton('按钮5'),1,Qt.AlignLeft | Qt.AlignBottom) 25 | hlayout.setSpacing(40) 26 | self.setLayout(hlayout) 27 | 28 | 29 | 30 | 31 | 32 | 33 | if __name__ == '__main__': 34 | app = QApplication(sys.argv) 35 | main = HBoxLayoutAlign() 36 | main.show() 37 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/web/InnerHTML.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 显示嵌入Web页面 4 | 5 | ''' 6 | 7 | from PyQt5.QtCore import * 8 | from PyQt5.QtGui import * 9 | from PyQt5.QtWidgets import * 10 | from PyQt5.QtWebEngineWidgets import * 11 | import sys 12 | import os 13 | class InnerHTML(QMainWindow): 14 | 15 | def __init__(self ): 16 | super(InnerHTML, self).__init__() 17 | self.setWindowTitle('显示嵌入Web页面') 18 | self.setGeometry(5, 30, 1355, 730) 19 | 20 | self.browser = QWebEngineView() 21 | self.browser.setHtml(''' 22 | 23 | 24 | 25 | 26 | 27 | 测试页面 28 | 29 | 30 |

Hello PyQt5

31 |

Hello PyQt5

32 |

Hello PyQt5

33 |

Hello PyQt5

34 | 35 | 36 | ''') 37 | self.setCentralWidget(self.browser) 38 | 39 | if __name__ == '__main__': 40 | app = QApplication(sys.argv) 41 | win = InnerHTML() 42 | win.show() 43 | sys.exit(app.exec_()) 44 | -------------------------------------------------------------------------------- /src/windows/ScaleImage.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 缩放图片 4 | 5 | QImage.scaled 6 | 7 | ''' 8 | 9 | from PyQt5.QtWidgets import QApplication, QLabel, QWidget, QVBoxLayout 10 | from PyQt5.QtGui import QImage, QPixmap 11 | from PyQt5.QtCore import Qt 12 | import sys 13 | 14 | 15 | class ScaleImage(QWidget): 16 | def __init__(self): 17 | super().__init__() 18 | self.setWindowTitle("图片大小缩放例子") 19 | filename = './images/Cloudy_72px.png' 20 | img = QImage(filename) 21 | label1 = QLabel(self) 22 | label1.setFixedWidth(200) 23 | label1.setFixedHeight(200) 24 | 25 | result = img.scaled(label1.width(),label1.height(),Qt.IgnoreAspectRatio,Qt.SmoothTransformation) 26 | label1.setPixmap(QPixmap.fromImage(result)) 27 | 28 | vbox = QVBoxLayout() 29 | vbox.addWidget(label1) 30 | 31 | self.setLayout(vbox) 32 | 33 | if __name__ == "__main__": 34 | app = QApplication(sys.argv) 35 | win = ScaleImage() 36 | win.show() 37 | sys.exit(app.exec_()) 38 | 39 | -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/StatusBar.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 创建和使用状态栏 4 | 5 | ''' 6 | 7 | import sys,math 8 | from PyQt5.QtWidgets import * 9 | from PyQt5.QtGui import * 10 | from PyQt5.QtCore import * 11 | 12 | class StatusBar(QMainWindow) : 13 | def __init__(self): 14 | super(StatusBar,self).__init__() 15 | self.initUI() 16 | def initUI(self): 17 | self.setWindowTitle("状态栏演示") 18 | self.resize(300,200) 19 | 20 | bar = self.menuBar() 21 | file = bar.addMenu("File") 22 | file.addAction("show") 23 | file.triggered.connect(self.processTrigger) 24 | self.setCentralWidget(QTextEdit()) 25 | self.statusBar = QStatusBar() 26 | self.setStatusBar(self.statusBar) 27 | 28 | 29 | def processTrigger(self,q): 30 | if q.text() == "show" : 31 | self.statusBar.showMessage(q.text() + " 菜单被点击了",5000) 32 | 33 | if __name__ == '__main__': 34 | app = QApplication(sys.argv) 35 | main = StatusBar() 36 | main.show() 37 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/containers/DockWidget.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 4 | 停靠控件(QDockWidget) 5 | 6 | ''' 7 | 8 | import sys 9 | from PyQt5.QtCore import * 10 | from PyQt5.QtGui import * 11 | from PyQt5.QtWidgets import * 12 | 13 | 14 | class DockDemo(QMainWindow): 15 | def __init__(self, parent=None): 16 | super(DockDemo, self).__init__(parent) 17 | 18 | self.setWindowTitle("停靠控件(QDockWidget)") 19 | 20 | layout = QHBoxLayout() 21 | self.items = QDockWidget('Dockable',self) 22 | self.listWidget = QListWidget() 23 | self.listWidget.addItem('item1') 24 | self.listWidget.addItem('item2') 25 | self.listWidget.addItem('item3') 26 | 27 | self.items.setWidget(self.listWidget) 28 | 29 | self.setCentralWidget(QLineEdit()) 30 | 31 | self.items.setFloating(True) 32 | 33 | self.addDockWidget(Qt.RightDockWidgetArea,self.items) 34 | 35 | 36 | 37 | 38 | if __name__ == '__main__': 39 | app = QApplication(sys.argv) 40 | demo = DockDemo() 41 | demo.show() 42 | sys.exit(app.exec_()) 43 | -------------------------------------------------------------------------------- /src/dialogs/QFontDialog.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 字体对话框:QFontDialog 4 | 5 | 6 | 7 | ''' 8 | 9 | import sys 10 | from PyQt5.QtCore import * 11 | from PyQt5.QtGui import * 12 | from PyQt5.QtWidgets import * 13 | class QFontDialogDemo(QWidget): 14 | def __init__(self): 15 | super(QFontDialogDemo,self).__init__() 16 | self.initUI() 17 | 18 | def initUI(self): 19 | self.setWindowTitle('Font Dialog例子') 20 | layout = QVBoxLayout() 21 | self.fontButton = QPushButton('选择字体') 22 | self.fontButton.clicked.connect(self.getFont) 23 | layout.addWidget(self.fontButton) 24 | 25 | self.fontLabel = QLabel('Hello,测试字体例子') 26 | layout.addWidget(self.fontLabel) 27 | 28 | self.setLayout(layout) 29 | def getFont(self): 30 | font, ok = QFontDialog.getFont() 31 | if ok : 32 | self.fontLabel.setFont(font) 33 | 34 | if __name__ == '__main__': 35 | app = QApplication(sys.argv) 36 | main = QFontDialogDemo() 37 | main.show() 38 | sys.exit(app.exec_()) 39 | 40 | -------------------------------------------------------------------------------- /src/windows/LoadQSS.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 装载QSS文件 4 | 5 | ''' 6 | 7 | import sys 8 | from PyQt5.QtWidgets import * 9 | from CommonHelper import CommonHelper 10 | 11 | class MainWindow(QMainWindow): 12 | def __init__(self, parent=None): 13 | super(MainWindow, self).__init__(parent) 14 | self.resize(477, 258) 15 | self.setWindowTitle("加载QSS文件") 16 | btn = QPushButton() 17 | btn.setText('装载QSS文件') 18 | btn.setToolTip('提示文本') 19 | 20 | vbox = QVBoxLayout() 21 | vbox.addWidget(btn) 22 | btn.clicked.connect(self.onClick) 23 | self.setLayout(vbox) 24 | 25 | widget = QWidget(self) 26 | self.setCentralWidget(widget) 27 | widget.setLayout(vbox) 28 | 29 | def onClick(self): 30 | styleFile = './style.qss' 31 | qssStyle = CommonHelper.readQSS(styleFile) 32 | win.setStyleSheet(qssStyle) 33 | 34 | 35 | if __name__ == "__main__": 36 | app = QApplication(sys.argv) 37 | win = MainWindow() 38 | 39 | win.show() 40 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/MoveWindow.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 用动画效果一不同速度移动窗口 4 | 5 | ''' 6 | 7 | from PyQt5.QtGui import * 8 | from PyQt5.QtCore import * 9 | from PyQt5.QtWidgets import * 10 | import sys 11 | 12 | app = QApplication(sys.argv) 13 | 14 | window1 = QMainWindow() 15 | window1.show() 16 | window2 = QMainWindow() 17 | window2.show() 18 | 19 | animation1 = QPropertyAnimation(window1, b'geometry') 20 | animation2 = QPropertyAnimation(window2, b'geometry') 21 | 22 | group = QParallelAnimationGroup() # 并行 23 | group = QSequentialAnimationGroup() # 串行 24 | 25 | group.addAnimation(animation1) 26 | group.addAnimation(animation2) 27 | 28 | animation1.setDuration(3000) 29 | animation1.setStartValue(QRect(0,0,100,30)) 30 | animation1.setEndValue(QRect(250,250,100,30)) 31 | animation1.setEasingCurve(QEasingCurve.OutBounce) 32 | 33 | animation2.setDuration(4000) 34 | animation2.setStartValue(QRect(250,150,100,30)) 35 | animation2.setEndValue(QRect(850,250,100,30)) 36 | animation2.setEasingCurve(QEasingCurve.CosineCurve) 37 | 38 | group.start() 39 | 40 | sys.exit(app.exec()) 41 | 42 | -------------------------------------------------------------------------------- /src/layout/Calc.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 栅格布局:实现计算器UI 4 | 5 | ''' 6 | 7 | import sys,math 8 | from PyQt5.QtWidgets import * 9 | 10 | 11 | class Calc(QWidget) : 12 | def __init__(self): 13 | super(Calc,self).__init__() 14 | self.setWindowTitle("栅格布局") 15 | 16 | grid = QGridLayout() 17 | self.setLayout(grid) 18 | 19 | names = ['Cls','Back','','Close', 20 | '7','8','9','/', 21 | '4','5','6','*', 22 | '1','2','3','-', 23 | '0','.','=','+'] 24 | 25 | positions = [(i,j) for i in range(5) for j in range(4)] 26 | print(positions) 27 | 28 | for position,name in zip(positions,names): 29 | if name == '': 30 | continue 31 | button = QPushButton(name) 32 | # print(position) 33 | grid.addWidget(button,*position) 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | if __name__ == '__main__': 44 | app = QApplication(sys.argv) 45 | main = Calc() 46 | main.show() 47 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/controls/QuitApplication.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QHBoxLayout,QMainWindow,QApplication,QPushButton,QWidget 3 | 4 | class QuitApplication(QMainWindow): 5 | def __init__(self): 6 | super(QuitApplication,self).__init__() 7 | self.resize(300,120) 8 | self.setWindowTitle('退出应用程序') 9 | 10 | # 添加Button 11 | 12 | self.button1 = QPushButton('退出应用程序') 13 | # 将信号与槽关联 14 | self.button1.clicked.connect(self.onClick_Button) 15 | 16 | layout = QHBoxLayout() 17 | layout.addWidget(self.button1) 18 | 19 | mainFrame = QWidget() 20 | mainFrame.setLayout(layout) 21 | 22 | self.setCentralWidget(mainFrame) 23 | 24 | # 按钮单击事件的方法(自定义的槽) 25 | def onClick_Button(self): 26 | sender = self.sender() 27 | print(sender.text() + ' 按钮被按下') 28 | app = QApplication.instance() 29 | # 退出应用程序 30 | app.quit() 31 | if __name__ == '__main__': 32 | app = QApplication(sys.argv) 33 | main = QuitApplication() 34 | main.show() 35 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/layout/Calc.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['Calc.py'], 7 | pathex=['/MyStudio/video_src/pycharm/pyqt5/src/layout'], 8 | binaries=[], 9 | datas=[], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=[], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher, 17 | noarchive=False) 18 | pyz = PYZ(a.pure, a.zipped_data, 19 | cipher=block_cipher) 20 | exe = EXE(pyz, 21 | a.scripts, 22 | a.binaries, 23 | a.zipfiles, 24 | a.datas, 25 | [], 26 | name='Calc', 27 | debug=False, 28 | bootloader_ignore_signals=False, 29 | strip=False, 30 | upx=True, 31 | runtime_tmpdir=None, 32 | console=False ) 33 | app = BUNDLE(exe, 34 | name='Calc.app', 35 | icon=None, 36 | bundle_identifier=None) 37 | -------------------------------------------------------------------------------- /src/printer/PrintSupport.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 使用打印机 4 | 5 | 6 | 7 | ''' 8 | 9 | from PyQt5 import QtGui, QtWidgets, QtPrintSupport 10 | from PyQt5.QtWidgets import * 11 | import sys 12 | 13 | class PrintSupport(QMainWindow): 14 | def __init__(self): 15 | super(PrintSupport,self).__init__() 16 | self.setGeometry(500, 200, 300, 300) 17 | self.button = QPushButton('打印QTextEdit控件中的内容',self) 18 | self.button.setGeometry(20,20,260,30) 19 | self.editor = QTextEdit('默认文本',self) 20 | self.editor.setGeometry(20,60,260,200) 21 | 22 | self.button.clicked.connect(self.print) 23 | 24 | def print(self): 25 | printer = QtPrintSupport.QPrinter() 26 | 27 | painter = QtGui.QPainter() 28 | # 将绘制的目标重定向到打印机 29 | painter.begin(printer) 30 | screen = self.editor.grab() 31 | painter.drawPixmap(10,10,screen) 32 | painter.end() 33 | print("print") 34 | 35 | 36 | if __name__ == '__main__': 37 | app = QtWidgets.QApplication(sys.argv) 38 | gui = PrintSupport() 39 | gui.show() 40 | app.exec_() -------------------------------------------------------------------------------- /src/SignalSlot/PartialSlotArg.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 使用Partial对象为槽函数传递参数 4 | 5 | 6 | ''' 7 | 8 | from PyQt5.QtWidgets import * 9 | import sys 10 | from functools import partial 11 | 12 | class PartialSlotArg(QMainWindow): 13 | def __init__(self): 14 | super().__init__() 15 | self.setWindowTitle("使用Partial表达式为槽函数传递参数") 16 | 17 | button1 = QPushButton("按钮1") 18 | button2 = QPushButton("按钮2") 19 | x = 20 20 | y = -123 21 | button1.clicked.connect(partial(self.onButtonClick,10,20)) 22 | button2.clicked.connect(partial(self.onButtonClick, x, y)) 23 | 24 | layout = QHBoxLayout() 25 | layout.addWidget(button1) 26 | layout.addWidget(button2) 27 | mainFrame = QWidget() 28 | mainFrame.setLayout(layout) 29 | self.setCentralWidget(mainFrame) 30 | def onButtonClick(self,m,n): 31 | print("m + n =",m + n ) 32 | QMessageBox.information(self,"结果",str(m+n)) 33 | if __name__ == "__main__": 34 | app = QApplication(sys.argv) 35 | form = PartialSlotArg() 36 | form.show() 37 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/web/f.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A Demo Page 4 | 5 | 6 | 35 | 36 | 37 | 38 |
39 | 40 | 41 |
42 | 43 | 44 |
45 | 46 | -------------------------------------------------------------------------------- /src/drawing/DrawText.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 绘图API:绘制文本 4 | 5 | 1. 文本 6 | 2. 各种图形(直线,点,椭圆,弧,扇形,多边形等) 7 | 3. 图像 8 | 9 | QPainter 10 | 11 | painter = QPainter() 12 | 13 | painter.begin() 14 | 15 | painter.drawText(...) 16 | 17 | painter.end() 18 | 19 | 20 | 必须在paintEvent事件方法中绘制各种元素 21 | 22 | 23 | ''' 24 | 25 | import sys 26 | from PyQt5.QtWidgets import QApplication,QWidget 27 | from PyQt5.QtGui import QPainter,QColor,QFont 28 | from PyQt5.QtCore import Qt 29 | 30 | class DrawText(QWidget): 31 | def __init__(self): 32 | super(DrawText,self).__init__() 33 | self.setWindowTitle('在窗口上绘制文本') 34 | self.resize(300,200) 35 | self.text = "Python从菜鸟到高手" 36 | def paintEvent(self, event): 37 | painter = QPainter(self) 38 | painter.begin(self) 39 | painter.setPen(QColor(150,43,5)) 40 | painter.setFont(QFont('SimSun',25)) 41 | 42 | painter.drawText(event.rect(),Qt.AlignCenter,self.text) 43 | painter.end() 44 | 45 | if __name__ == '__main__': 46 | app = QApplication(sys.argv) 47 | main = DrawText() 48 | main.show() 49 | sys.exit(app.exec_()) 50 | -------------------------------------------------------------------------------- /src/layout/GridForm.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 栅格布局:表单设计 4 | 5 | ''' 6 | 7 | import sys,math 8 | from PyQt5.QtWidgets import * 9 | 10 | 11 | class GridForm(QWidget) : 12 | def __init__(self): 13 | super(GridForm,self).__init__() 14 | self.setWindowTitle("栅格布局:表单设计") 15 | 16 | titleLabel = QLabel('标题') 17 | authorLabel = QLabel('作者') 18 | contentLabel = QLabel('内容') 19 | 20 | titleEdit = QLineEdit() 21 | authorEdit = QLineEdit() 22 | contentEdit = QTextEdit() 23 | 24 | grid = QGridLayout() 25 | grid.setSpacing(10) 26 | 27 | grid.addWidget(titleLabel,1,0) 28 | grid.addWidget(titleEdit,1,1) 29 | 30 | grid.addWidget(authorLabel,2,0) 31 | grid.addWidget(authorEdit,2,1) 32 | 33 | grid.addWidget(contentLabel,3,0) 34 | grid.addWidget(contentEdit,3,1,5,1) 35 | 36 | self.setLayout(grid) 37 | self.resize(350,300) 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | if __name__ == '__main__': 47 | app = QApplication(sys.argv) 48 | main = GridForm() 49 | main.show() 50 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/SignalSlot/DateDialog.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import * 2 | from PyQt5.QtGui import * 3 | from PyQt5.QtWidgets import * 4 | 5 | class DateDialog(QDialog): 6 | def __init__(self,parent=None): 7 | super(DateDialog,self).__init__(parent) 8 | self.setWindowTitle("DateDialog") 9 | 10 | layout = QVBoxLayout(self) 11 | self.datetime = QDateTimeEdit(self) 12 | self.datetime.setCalendarPopup(True) 13 | self.datetime.setDateTime(QDateTime.currentDateTime()) 14 | 15 | layout.addWidget(self.datetime) 16 | 17 | buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel,Qt.Horizontal,self) 18 | buttons.accepted.connect(self.accept) 19 | buttons.rejected.connect(self.reject) 20 | 21 | layout.addWidget(buttons) 22 | 23 | def dateTime(self): 24 | return self.datetime.dateTime() 25 | 26 | @staticmethod 27 | def getDateTime(parent = None): 28 | dialog = DateDialog(parent) 29 | result = dialog.exec() 30 | date = dialog.dateTime() 31 | return (date.date(),date.time(),result == QDialog.Accepted) 32 | 33 | -------------------------------------------------------------------------------- /src/table_tree/ListView.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 显示列表数据(QListView控件) 4 | 5 | ''' 6 | 7 | from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QListView, QMessageBox 8 | from PyQt5.QtCore import QStringListModel 9 | import sys 10 | 11 | 12 | class ListViewDemo(QWidget): 13 | def __init__(self, parent=None): 14 | super(ListViewDemo, self).__init__(parent) 15 | self.setWindowTitle("QListView 例子") 16 | self.resize(300, 270) 17 | layout = QVBoxLayout() 18 | 19 | listview = QListView() 20 | listModel = QStringListModel() 21 | self.list = ["列表项1","列表项2", "列表项3"] 22 | 23 | listModel.setStringList(self.list) 24 | 25 | listview.setModel(listModel) 26 | listview.clicked.connect(self.clicked) 27 | layout.addWidget(listview) 28 | 29 | self.setLayout(layout) 30 | 31 | def clicked(self,item): 32 | QMessageBox.information(self,"QListView","您选择了:" + self.list[item.row()]) 33 | 34 | 35 | 36 | if __name__ == "__main__": 37 | app = QApplication(sys.argv) 38 | win = ListViewDemo() 39 | win.show() 40 | sys.exit(app.exec_()) 41 | -------------------------------------------------------------------------------- /src/controls/QSpinBoxDemo.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 计数器控件(QSpinBox) 4 | 5 | 6 | 7 | ''' 8 | 9 | import sys 10 | from PyQt5.QtCore import * 11 | from PyQt5.QtGui import * 12 | from PyQt5.QtWidgets import * 13 | 14 | class QSpinBoxDemo(QWidget): 15 | def __init__(self): 16 | super(QSpinBoxDemo,self).__init__() 17 | self.initUI() 18 | 19 | def initUI(self): 20 | self.setWindowTitle('QSpinBox演示') 21 | self.resize(300,100) 22 | 23 | layout = QVBoxLayout() 24 | self.label = QLabel('当前值') 25 | self.label.setAlignment(Qt.AlignCenter) 26 | 27 | layout.addWidget(self.label) 28 | 29 | self.sb = QSpinBox() 30 | self.sb.setValue(18) 31 | self.sb.setRange(10,38) 32 | self.sb.setSingleStep(3) 33 | layout.addWidget(self.sb) 34 | self.sb.valueChanged.connect(self.valueChange) 35 | self.setLayout(layout) 36 | 37 | def valueChange(self): 38 | self.label.setText('当前值:' + str(self.sb.value())) 39 | 40 | if __name__ == '__main__': 41 | app = QApplication(sys.argv) 42 | main = QSpinBoxDemo() 43 | main.show() 44 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/makeppa.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # package info 4 | ppa="ppa:colin-duquesnoy/stable" 5 | name="qdarkstyle" 6 | version="2.0" 7 | 8 | # read pgp key from gpg_key file 9 | gpg_key=`cat gpg_key` 10 | 11 | # generate debian source package and .orig.tar.gz 12 | python3 setup.py --command-packages=stdeb.command sdist_dsc 13 | 14 | date=`date -R` 15 | 16 | # clean pyc files 17 | find . -name "*.pyc" -exec rm -rf {} \; 18 | 19 | 20 | for suite in 'trusty' 'utopic' 'vivid' 21 | do 22 | # sign our package and prepare it for ppa upload 23 | pushd deb_dist 24 | pushd ${name}-${version} 25 | 26 | # update changelog to include ubuntu release 27 | changelog="${name} (${version}-1ppa1~${suite}1) ${suite}; urgency=low 28 | * Initial release 29 | -- Colin Duquesnoy ${date} 30 | " 31 | echo "$changelog" > debian/changelog 32 | cat debian/changelog 33 | 34 | debuild -S -sa -k${gpg_key} 35 | popd 36 | 37 | # upload to ppa 38 | dput ${ppa} *.changes 39 | rm -rf *.dsc *.changes 40 | 41 | popd 42 | done 43 | 44 | # cleanup 45 | rm -rf *.tar.gz deb_dist/ dist/ 46 | -------------------------------------------------------------------------------- /src/layout/RightBottomButton.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 让按钮永远在窗口右下角 4 | 5 | 6 | ''' 7 | 8 | import sys,math 9 | from PyQt5.QtWidgets import * 10 | from PyQt5.QtCore import Qt 11 | 12 | 13 | class RightBottomButton(QWidget) : 14 | def __init__(self): 15 | super(RightBottomButton,self).__init__() 16 | self.setWindowTitle("让按钮永远在右下角") 17 | self.resize(400,300) 18 | 19 | okButton = QPushButton("确定") 20 | cancelButton = QPushButton("取消") 21 | 22 | hbox = QHBoxLayout() 23 | hbox.addStretch(1) 24 | hbox.addWidget(okButton) 25 | hbox.addWidget(cancelButton) 26 | 27 | vbox = QVBoxLayout() 28 | btn1 = QPushButton("按钮1") 29 | btn2 = QPushButton("按钮2") 30 | btn3 = QPushButton("按钮3") 31 | 32 | vbox.addStretch(0) 33 | vbox.addWidget(btn1) 34 | vbox.addWidget(btn2) 35 | vbox.addWidget(btn3) 36 | vbox.addStretch(1) 37 | vbox.addLayout(hbox) 38 | 39 | self.setLayout(vbox) 40 | 41 | 42 | 43 | 44 | 45 | if __name__ == '__main__': 46 | app = QApplication(sys.argv) 47 | main = RightBottomButton() 48 | main.show() 49 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/web/tt.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 测试页面 6 | 20 | 21 | 22 |
23 | 24 | 25 |
26 | 27 | 28 |
29 | 30 | 31 |
32 | 33 |
34 | 35 | -------------------------------------------------------------------------------- /src/SignalSlot/AutoSignalSlot.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 信号与槽自动连接 3 | 4 | on_objectname_signalname 5 | 6 | on_okButton_clicked 7 | 8 | ''' 9 | 10 | from PyQt5 import QtCore 11 | from PyQt5.QtWidgets import QApplication ,QWidget ,QHBoxLayout , QPushButton 12 | import sys 13 | 14 | class AutoSignalSlot(QWidget): 15 | def __init__(self): 16 | super(AutoSignalSlot,self).__init__() 17 | self.okButton = QPushButton("ok",self) 18 | self.okButton.setObjectName("okButton") 19 | self.okButton1 = QPushButton("cancel",self) 20 | self.okButton1.setObjectName("cancelButton") 21 | layout = QHBoxLayout() 22 | layout.addWidget(self.okButton) 23 | self.setLayout(layout) 24 | QtCore.QMetaObject.connectSlotsByName(self) 25 | #self.okButton.clicked.connect(self.on_okButton_clicked) 26 | 27 | @QtCore.pyqtSlot() 28 | def on_okButton_clicked(self): 29 | print("点击了ok按钮") 30 | 31 | @QtCore.pyqtSlot() 32 | def on_cancelButton_clicked(self): 33 | print("点击了cancel按钮") 34 | if __name__ == '__main__': 35 | app = QApplication(sys.argv) 36 | example = AutoSignalSlot() 37 | example.show() 38 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/COPYING: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) <2013-2017> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/example/example_pyqt5.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['example_pyqt5.py'], 7 | pathex=['/MyStudio/resources/PyQt5/src/window_graghics_effect/QDarkStyleSheet-master/example'], 8 | binaries=[], 9 | datas=[], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=[], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher, 17 | noarchive=False) 18 | pyz = PYZ(a.pure, a.zipped_data, 19 | cipher=block_cipher) 20 | exe = EXE(pyz, 21 | a.scripts, 22 | a.binaries, 23 | a.zipfiles, 24 | a.datas, 25 | [], 26 | name='example_pyqt5', 27 | debug=False, 28 | bootloader_ignore_signals=False, 29 | strip=False, 30 | upx=True, 31 | runtime_tmpdir=None, 32 | console=False ) 33 | app = BUNDLE(exe, 34 | name='example_pyqt5.app', 35 | icon=None, 36 | bundle_identifier=None) 37 | -------------------------------------------------------------------------------- /src/drawing/FillRect.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 用画刷填充图形区域 4 | 5 | ''' 6 | 7 | import sys,math 8 | from PyQt5.QtWidgets import * 9 | from PyQt5.QtGui import * 10 | from PyQt5.QtCore import * 11 | 12 | class FillRect(QWidget): 13 | def __init__(self): 14 | super(FillRect,self).__init__() 15 | self.resize(600,600) 16 | self.setWindowTitle('用画刷填充区域') 17 | 18 | def paintEvent(self,e): 19 | qp = QPainter() 20 | qp.begin(self) 21 | brush = QBrush(Qt.SolidPattern) 22 | qp.setBrush(brush) 23 | qp.drawRect(10,15,90,60) 24 | 25 | brush = QBrush(Qt.Dense1Pattern) 26 | qp.setBrush(brush) 27 | qp.drawRect(130,15,90,60) 28 | 29 | brush = QBrush(Qt.Dense2Pattern) 30 | qp.setBrush(brush) 31 | qp.drawRect(250,15,90,60) 32 | 33 | brush = QBrush(Qt.Dense3Pattern) 34 | qp.setBrush(brush) 35 | qp.drawRect(10, 105, 90, 60) 36 | 37 | brush = QBrush(Qt.HorPattern) 38 | qp.setBrush(brush) 39 | qp.drawRect(130, 105, 90, 60) 40 | qp.end() 41 | 42 | if __name__ == '__main__': 43 | app = QApplication(sys.argv) 44 | main = FillRect() 45 | main.show() 46 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/SignalSlot/NNSignal.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 信号槽N对N连接与断开连接 4 | 5 | 6 | 7 | ''' 8 | 9 | from PyQt5.QtCore import * 10 | 11 | class NNSignal(QObject): 12 | signal1 = pyqtSignal() 13 | signal2 = pyqtSignal(int) 14 | signal3 = pyqtSignal() 15 | def __init__(self): 16 | super(NNSignal,self).__init__() 17 | 18 | self.signal1.connect(self.call1) 19 | self.signal1.connect(self.call11) 20 | 21 | self.signal3.connect(self.call1) 22 | self.signal1.emit() 23 | self.signal3.emit() 24 | ''' 25 | self.signal2.connect(self.signal1) 26 | 27 | self.signal2.emit(2) # 触发了信号1 28 | 29 | self.signal1.disconnect(self.call1) 30 | self.signal1.disconnect(self.call11) 31 | self.signal2.disconnect(self.signal1) 32 | 33 | self.signal1.connect(self.call1) 34 | self.signal2.connect(self.call2) 35 | 36 | self.signal1.emit() 37 | self.signal2.emit(100) 38 | ''' 39 | def call1(self): 40 | print("call1 emit") 41 | 42 | def call11(self): 43 | print("call11 emit") 44 | 45 | def call2(self,val): 46 | print("call2 emit:",val) 47 | if __name__ == '__main__': 48 | nnSignal = NNSignal() -------------------------------------------------------------------------------- /src/dialogs/QDialogDemo.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 对话框:QDialog 4 | 5 | QMessageBox 6 | QColorDialog 7 | QFileDialog 8 | QFontDialog 9 | QInputDialog 10 | 11 | QMainWindow 12 | QWidget 13 | QDialog 14 | 15 | ''' 16 | 17 | import sys 18 | from PyQt5.QtCore import * 19 | from PyQt5.QtGui import * 20 | from PyQt5.QtWidgets import * 21 | class QDialogDemo(QMainWindow): 22 | def __init__(self): 23 | super(QDialogDemo,self).__init__() 24 | self.initUI() 25 | 26 | def initUI(self): 27 | self.setWindowTitle('QDialog案例') 28 | self.resize(300,200) 29 | 30 | self.button = QPushButton(self) 31 | self.button.setText('弹出对话框') 32 | self.button.move(50,50) 33 | self.button.clicked.connect(self.showDialog) 34 | 35 | def showDialog(self): 36 | dialog = QDialog() 37 | button = QPushButton('确定',dialog) 38 | button.clicked.connect(dialog.close) 39 | button.move(50,50) 40 | dialog.setWindowTitle('对话框') 41 | dialog.setWindowModality(Qt.ApplicationModal) 42 | 43 | dialog.exec() 44 | 45 | if __name__ == '__main__': 46 | app = QApplication(sys.argv) 47 | main = QDialogDemo() 48 | main.show() 49 | sys.exit(app.exec_()) 50 | 51 | -------------------------------------------------------------------------------- /src/calendar_time/MyCalendar.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 日历控件 3 | 4 | QCalendarWidget 5 | 6 | ''' 7 | 8 | import sys,math 9 | from PyQt5.QtWidgets import * 10 | from PyQt5.QtGui import * 11 | from PyQt5.QtCore import * 12 | 13 | class MyCalendar(QWidget): 14 | def __init__(self): 15 | super(MyCalendar, self).__init__() 16 | self.initUI() 17 | def initUI(self): 18 | self.cal = QCalendarWidget(self) 19 | self.cal.setMinimumDate(QDate(1988,1,1)) 20 | self.cal.setMaximumDate(QDate(2088,1,1)) 21 | 22 | self.cal.setGridVisible(True) 23 | self.cal.move(20,20) 24 | self.cal.clicked.connect(self.showDate) 25 | self.label = QLabel(self) 26 | date = self.cal.selectedDate() 27 | self.label.setText(date.toString("yyyy-MM-dd dddd")) 28 | self.label.move(20,300) 29 | 30 | self.resize(400,350) 31 | self.setWindowTitle("日历演示") 32 | 33 | def showDate(self,date): 34 | #self.label.setText((date.toString("yyyy-MM-dd dddd"))) 35 | self.label.setText((self.cal.selectedDate().toString("yyyy-MM-dd dddd"))) 36 | 37 | if __name__ == '__main__': 38 | app = QApplication(sys.argv) 39 | main = MyCalendar() 40 | main.show() 41 | sys.exit(app.exec_()) 42 | -------------------------------------------------------------------------------- /src/layout/Splitter.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 拖动控件之间的边界(QSplitter) 4 | 5 | ''' 6 | 7 | import sys 8 | from PyQt5.QtCore import * 9 | from PyQt5.QtGui import * 10 | from PyQt5.QtWidgets import * 11 | 12 | 13 | class Splitter(QWidget): 14 | def __init__(self): 15 | super(Splitter, self).__init__() 16 | self.initUI() 17 | 18 | def initUI(self): 19 | hbox = QHBoxLayout(self) 20 | self.setWindowTitle('QSplitter 例子') 21 | self.setGeometry(300, 300, 300, 200) 22 | 23 | topleft = QFrame() 24 | topleft.setFrameShape(QFrame.StyledPanel) 25 | 26 | bottom = QFrame() 27 | bottom.setFrameShape(QFrame.StyledPanel) 28 | 29 | splitter1 = QSplitter(Qt.Horizontal) 30 | textedit = QTextEdit() 31 | splitter1.addWidget(topleft) 32 | splitter1.addWidget(textedit) 33 | splitter1.setSizes([200,100]) 34 | 35 | splitter2 = QSplitter(Qt.Vertical) 36 | splitter2.addWidget(splitter1) 37 | splitter2.addWidget(bottom) 38 | 39 | 40 | hbox.addWidget(splitter2) 41 | self.setLayout(hbox) 42 | 43 | if __name__ == '__main__': 44 | app = QApplication(sys.argv) 45 | demo = Splitter() 46 | demo.show() 47 | sys.exit(app.exec_()) 48 | 49 | -------------------------------------------------------------------------------- /src/controls/QRadioButtonDemo.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 单选按钮控件(QRadioButton) 4 | 5 | ''' 6 | 7 | import sys 8 | from PyQt5.QtCore import * 9 | from PyQt5.QtGui import * 10 | from PyQt5.QtWidgets import * 11 | 12 | class QRadioButtonDemo(QWidget): 13 | def __init__(self): 14 | super(QRadioButtonDemo,self).__init__() 15 | self.initUI() 16 | def initUI(self): 17 | self.setWindowTitle('QRadioButton') 18 | layout = QHBoxLayout() 19 | self.button1 = QRadioButton('单选按钮1') 20 | self.button1.setChecked(True) 21 | 22 | self.button1.toggled.connect(self.buttonState) 23 | layout.addWidget(self.button1) 24 | 25 | self.button2 = QRadioButton('单选按钮2') 26 | self.button2.toggled.connect(self.buttonState) 27 | layout.addWidget(self.button2) 28 | self.setLayout(layout) 29 | 30 | 31 | def buttonState(self): 32 | radioButton = self.sender() 33 | 34 | if radioButton.isChecked() == True: 35 | print('<' + radioButton.text() + '> 被选中') 36 | else: 37 | print('<' + radioButton.text() + '> 被取消选中状态') 38 | 39 | 40 | if __name__ == '__main__': 41 | app = QApplication(sys.argv) 42 | main = QRadioButtonDemo() 43 | main.show() 44 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/SignalSlot/ThreadUpdateUI.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 多线程更新UI数据(在两个线程中传递数据) 4 | 5 | ''' 6 | 7 | from PyQt5.QtCore import QThread , pyqtSignal, QDateTime 8 | from PyQt5.QtWidgets import QApplication, QDialog, QLineEdit 9 | import time 10 | import sys 11 | 12 | 13 | class BackendThread(QThread): 14 | update_date = pyqtSignal(str) 15 | 16 | def run(self): 17 | while True: 18 | data = QDateTime.currentDateTime() 19 | currentTime = data.toString("yyyy-MM-dd hh:mm:ss") 20 | self.update_date.emit(str(currentTime)) 21 | time.sleep(1) 22 | class ThreadUpdateUI(QDialog): 23 | def __init__(self): 24 | QDialog.__init__(self) 25 | self.setWindowTitle('多线程更新UI数据') 26 | self.resize(400,100) 27 | self.input = QLineEdit(self) 28 | self.input.resize(400,100) 29 | 30 | self.initUI() 31 | def initUI(self): 32 | self.backend = BackendThread() 33 | self.backend.update_date.connect(self.handleDisplay) 34 | 35 | self.backend.start() 36 | 37 | def handleDisplay(self,data): 38 | self.input.setText(data) 39 | if __name__ == '__main__': 40 | app = QApplication(sys.argv) 41 | example = ThreadUpdateUI() 42 | example.show() 43 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/SignalSlot/LambdaSlotArg.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 使用Lambda表达式为槽函数传递参数 4 | 5 | Lambda表达式:匿名函数,也就是没有名字的函数 6 | 7 | fun = lambda :print("hello world") 8 | 9 | fun() 10 | 11 | fun1 = lambda x,y:print(x,y) 12 | fun1("a","b") 13 | 14 | 15 | ''' 16 | 17 | from PyQt5.QtWidgets import * 18 | import sys 19 | 20 | class LambdaSlotArg(QMainWindow): 21 | def __init__(self): 22 | super().__init__() 23 | self.setWindowTitle("使用Lambda表达式为槽函数传递参数") 24 | 25 | button1 = QPushButton("按钮1") 26 | button2 = QPushButton("按钮2") 27 | ok = 100 28 | button1.clicked.connect(lambda :self.onButtonClick(10,ok)) 29 | button2.clicked.connect(lambda :self.onButtonClick(ok,-20)) 30 | button1.clicked.connect(lambda :QMessageBox.information(self,"结果","单击了button1")) 31 | 32 | layout = QHBoxLayout() 33 | layout.addWidget(button1) 34 | layout.addWidget(button2) 35 | mainFrame = QWidget() 36 | mainFrame.setLayout(layout) 37 | self.setCentralWidget(mainFrame) 38 | def onButtonClick(self,m,n): 39 | print("m + n =",m + n ) 40 | QMessageBox.information(self,"结果",str(m+n)) 41 | if __name__ == "__main__": 42 | app = QApplication(sys.argv) 43 | form = LambdaSlotArg() 44 | form.show() 45 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/WindowStyle.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 窗口、绘图与特效:设置窗口风格 4 | 5 | 设置窗口中控件的风格 6 | 7 | QApplication.setStyle(...) 8 | 9 | ''' 10 | 11 | import sys 12 | from PyQt5.QtWidgets import * 13 | from PyQt5.QtCore import * 14 | from PyQt5 import QtCore 15 | from PyQt5.QtGui import * 16 | 17 | class WindowStyle(QWidget): 18 | def __init__(self): 19 | super().__init__() 20 | self.setWindowTitle('设置窗口风格') 21 | horizontalLayout = QHBoxLayout() 22 | self.styleLabel = QLabel('设置窗口风格:') 23 | self.styleComboBox = QComboBox() 24 | self.styleComboBox.addItems(QStyleFactory.keys()) 25 | 26 | # 获取当前窗口的风格 27 | print(QApplication.style().objectName()) 28 | index = self.styleComboBox.findText(QApplication.style().objectName(),QtCore.Qt.MatchFixedString) 29 | 30 | self.styleComboBox.setCurrentIndex(index) 31 | 32 | self.styleComboBox.activated[str].connect(self.handleStyleChanged) 33 | horizontalLayout.addWidget(self.styleLabel) 34 | horizontalLayout.addWidget(self.styleComboBox) 35 | self.setLayout(horizontalLayout) 36 | def handleStyleChanged(self,style): 37 | QApplication.setStyle(style) 38 | 39 | if __name__ == "__main__": 40 | app = QApplication(sys.argv) 41 | form = WindowStyle() 42 | form.show() 43 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/controls/QLabelBuddy.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | QLabel与伙伴控件 4 | 5 | mainLayout.addWidget(控件对象,rowIndex,columnIndex,row,column) 6 | 7 | ''' 8 | 9 | from PyQt5.QtWidgets import * 10 | import sys 11 | 12 | class QLabelBuddy(QDialog) : 13 | def __init__(self): 14 | super().__init__() 15 | self.initUI() 16 | 17 | def initUI(self): 18 | self.setWindowTitle('QLabel与伙伴控件') 19 | 20 | nameLabel = QLabel('&Name',self) 21 | nameLineEdit = QLineEdit(self) 22 | # 设置伙伴控件 23 | nameLabel.setBuddy(nameLineEdit) 24 | 25 | passwordLabel = QLabel('&Password',self) 26 | passwordLineEdit = QLineEdit(self) 27 | # 设置伙伴控件 28 | passwordLabel.setBuddy(passwordLineEdit) 29 | 30 | btnOK = QPushButton('&OK') 31 | btnCancel = QPushButton('&Cancel') 32 | 33 | mainLayout = QGridLayout(self) 34 | mainLayout.addWidget(nameLabel,0,0) 35 | mainLayout.addWidget(nameLineEdit,0,1,1,2) 36 | 37 | mainLayout.addWidget(passwordLabel,1,0) 38 | mainLayout.addWidget(passwordLineEdit,1,1,1,2) 39 | 40 | mainLayout.addWidget(btnOK,2,1) 41 | mainLayout.addWidget(btnCancel,2,2) 42 | 43 | if __name__ == '__main__': 44 | app = QApplication(sys.argv) 45 | main = QLabelBuddy() 46 | main.show() 47 | sys.exit(app.exec_()) 48 | -------------------------------------------------------------------------------- /src/drapclip/DrapDrop.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 让控件支持拖拽动作 3 | A.setDragEnabled(True) 4 | 5 | B.setAcceptDrops(True) 6 | 7 | B需要两个事件 8 | 1. dragEnterEvent 将A拖到B触发 9 | 2. dropEvent 在B的区域放下A时触发 10 | 11 | 12 | ''' 13 | 14 | import sys,math 15 | from PyQt5.QtWidgets import * 16 | from PyQt5.QtGui import * 17 | from PyQt5.QtCore import * 18 | 19 | class MyComboBox(QComboBox) : 20 | def __init__(self): 21 | super(MyComboBox,self).__init__() 22 | self.setAcceptDrops(True) 23 | def dragEnterEvent(self,e): 24 | print(e) 25 | if e.mimeData().hasText(): 26 | e.accept() 27 | else: 28 | e.ignore() 29 | def dropEvent(self,e): 30 | self.addItem(e.mimeData().text()) 31 | 32 | class DrapDropDemo(QWidget): 33 | def __init__(self): 34 | super(DrapDropDemo,self).__init__() 35 | formLayout = QFormLayout() 36 | formLayout.addRow(QLabel("请将左边的文本拖拽到右边的下拉列表中")) 37 | lineEdit = QLineEdit() 38 | lineEdit.setDragEnabled(True) # 让QLineEdit控件可拖动 39 | 40 | combo = MyComboBox() 41 | formLayout.addRow(lineEdit,combo) 42 | self.setLayout(formLayout) 43 | self.setWindowTitle('拖拽案例') 44 | if __name__ == '__main__': 45 | app = QApplication(sys.argv) 46 | main = DrapDropDemo() 47 | main.show() 48 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/table_tree/Span.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 合并单元格 4 | 5 | setSpan(row,col,要合并的行数,要合并的列数) 6 | 7 | ''' 8 | 9 | import sys 10 | from PyQt5.QtWidgets import (QWidget, QTableWidget, QHBoxLayout, QApplication, QTableWidgetItem) 11 | 12 | 13 | class Span(QWidget): 14 | def __init__(self): 15 | super(Span,self).__init__() 16 | self.initUI() 17 | 18 | def initUI(self): 19 | self.setWindowTitle("合并单元格") 20 | self.resize(430, 230); 21 | layout = QHBoxLayout() 22 | tableWidget = QTableWidget() 23 | tableWidget.setRowCount(4) 24 | tableWidget.setColumnCount(3) 25 | layout.addWidget(tableWidget) 26 | 27 | tableWidget.setHorizontalHeaderLabels(['姓名', '性别', '体重(kg)']) 28 | 29 | newItem = QTableWidgetItem('雷神') 30 | tableWidget.setItem(0,0,newItem) 31 | tableWidget.setSpan(0, 0, 3, 1) 32 | 33 | newItem = QTableWidgetItem('男') 34 | tableWidget.setItem(0,1,newItem) 35 | tableWidget.setSpan(0,1,2,1) 36 | 37 | newItem = QTableWidgetItem('160') 38 | tableWidget.setItem(0,2,newItem) 39 | tableWidget.setSpan(0,2,4,1) 40 | 41 | 42 | self.setLayout(layout) 43 | 44 | 45 | if __name__ == '__main__': 46 | app = QApplication(sys.argv) 47 | example = Span() 48 | example.show() 49 | sys.exit(app.exec_()) 50 | -------------------------------------------------------------------------------- /src/table_tree/CellImageText.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 在单元格中实现图文混排的效果 4 | 5 | ''' 6 | 7 | import sys 8 | from PyQt5.QtWidgets import * 9 | from PyQt5.QtGui import * 10 | 11 | 12 | 13 | class CellImageText(QWidget): 14 | 15 | def __init__(self): 16 | super(CellImageText,self).__init__() 17 | self.initUI() 18 | def initUI(self): 19 | self.setWindowTitle("在单元格中实现图文混排的效果") 20 | self.resize(500, 300); 21 | layout = QHBoxLayout() 22 | self.tableWidget = QTableWidget() 23 | self.tableWidget.setRowCount(5) 24 | self.tableWidget.setColumnCount(4) 25 | layout.addWidget(self.tableWidget) 26 | 27 | self.tableWidget.setHorizontalHeaderLabels(['姓名', '性别', '体重', '显示图片']) 28 | 29 | newItem = QTableWidgetItem('李宁') 30 | self.tableWidget.setItem(0,0,newItem) 31 | 32 | newItem = QTableWidgetItem('男') 33 | self.tableWidget.setItem(0,1,newItem) 34 | newItem = QTableWidgetItem('160') 35 | self.tableWidget.setItem(0,2,newItem) 36 | 37 | newItem = QTableWidgetItem(QIcon('./images/bao1.png'),'背包') 38 | self.tableWidget.setItem(0,3,newItem) 39 | 40 | 41 | 42 | self.setLayout(layout) 43 | 44 | 45 | if __name__ == '__main__': 46 | app = QApplication(sys.argv) 47 | example = CellImageText() 48 | example.show() 49 | sys.exit(app.exec_()) 50 | -------------------------------------------------------------------------------- /src/web/PyQtCallJS.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | PyQt5调用JavaScript代码 4 | 5 | 6 | PyQt5和JavaScript交互 7 | 8 | 什么叫交互 9 | 10 | PyQt5 <-> JavaScript 11 | 12 | 13 | 14 | 15 | ''' 16 | 17 | 18 | from PyQt5.QtCore import * 19 | from PyQt5.QtGui import * 20 | from PyQt5.QtWidgets import * 21 | from PyQt5.QtWebEngineWidgets import * 22 | import sys 23 | import os 24 | 25 | 26 | class PyQtCallJS(QWidget): 27 | 28 | def __init__(self): 29 | super(PyQtCallJS, self).__init__() 30 | self.setWindowTitle('PyQt5调用JavaScript') 31 | self.setGeometry(5, 30, 1355, 730) 32 | self.layout = QVBoxLayout() 33 | self.setLayout(self.layout) 34 | self.browser = QWebEngineView() 35 | 36 | url = os.getcwd() + '/tt.html' 37 | self.browser.load(QUrl.fromLocalFile(url)) 38 | 39 | self.layout.addWidget(self.browser) 40 | 41 | button = QPushButton('设置全名') 42 | button.clicked.connect(self.fullname) 43 | self.layout.addWidget(button) 44 | 45 | def js_callback(self,result): 46 | print(result) 47 | def fullname(self): 48 | self.value = 'hello world' 49 | self.browser.page().runJavaScript('fullname("' + self.value + '");',self.js_callback) 50 | if __name__ == '__main__': 51 | app = QApplication(sys.argv) 52 | win = PyQtCallJS() 53 | win.show() 54 | sys.exit(app.exec_()) 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Submitter: Colin Duquesnoy 2 | # Maintainer: Colin Duquesnoy 3 | pkgbase=python-qdarkstyle 4 | pkgname=('python2-qdarkstyle' 'python-qdarkstyle') 5 | pkgver=1.16 6 | _pkgver=1.16 7 | pkgrel=1 8 | arch=('any') 9 | url="https://github.com/davidhalter/qdarkstyle" 10 | license=('MIT') 11 | depends=('python2') 12 | makedepends=('python2-setuptools' 'python-setuptools') 13 | source=("https://pypi.python.org/packages/source/Q/QDarkStyle/QDarkStyle-${_pkgver}.tar.gz") 14 | md5sums=('6d742d304406a1a6733a27542402ce82') 15 | 16 | build() { 17 | cd "$srcdir/QDarkStyle-${_pkgver}" 18 | } 19 | 20 | package_python-qdarkstyle() { 21 | pkgdesc="A dark stylesheet for pyside/pyqt applications" 22 | depends=('python') 23 | cd "$srcdir/QDarkStyle-${_pkgver}" 24 | python3 setup.py install --root="$pkgdir/" --optimize=1 25 | 26 | install -D -m644 "$srcdir/QDarkStyle-${_pkgver}/COPYING" $pkgdir/usr/share/licenses/$pkgname/LICENSE 27 | } 28 | 29 | package_python2-qdarkstyle() { 30 | pkgdesc="A dark stylesheet for pyside/pyqt applications" 31 | depends=('python2') 32 | cd "$srcdir/QDarkStyle-${_pkgver}" 33 | python2 setup.py install --root="$pkgdir/" --optimize=1 34 | 35 | install -D -m644 "$srcdir/QDarkStyle-${_pkgver}/COPYING" $pkgdir/usr/share/licenses/$pkgname/LICENSE 36 | } 37 | -------------------------------------------------------------------------------- /src/web/PyFactorial.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | from PyQt5.QtWebEngineWidgets import QWebEngineView 3 | from PyQt5.QtCore import * 4 | from MySharedObject import MySharedObject 5 | from PyQt5.QtWebChannel import QWebChannel 6 | import sys 7 | import os 8 | 9 | ''' 10 | 11 | JavaScript调用Python函数计算阶乘 12 | 13 | 将Python的一个对象映射到JavaScript中 14 | 15 | 将槽函数映射到JavaScript中 16 | 17 | 18 | 19 | 20 | ''' 21 | 22 | from PyQt5.QtCore import * 23 | from PyQt5.QtGui import * 24 | from PyQt5.QtWidgets import * 25 | from PyQt5.QtWebEngineWidgets import * 26 | import sys 27 | import os 28 | from factorial import * 29 | 30 | channel = QWebChannel() 31 | factorial = Factorial() 32 | class PyFactorial(QWidget): 33 | 34 | def __init__(self): 35 | super(PyFactorial, self).__init__() 36 | self.setWindowTitle('Python计算阶乘') 37 | self.resize(600,300) 38 | layout=QVBoxLayout() 39 | 40 | self.browser = QWebEngineView() 41 | url = os.getcwd() + '/f.html' 42 | self.browser.load(QUrl.fromLocalFile(url)) 43 | channel.registerObject("obj",factorial) 44 | self.browser.page().setWebChannel(channel) 45 | 46 | layout.addWidget(self.browser) 47 | self.setLayout(layout) 48 | 49 | 50 | if __name__ == '__main__': 51 | app = QApplication(sys.argv) 52 | win = PyFactorial() 53 | win.show() 54 | sys.exit(app.exec_()) 55 | -------------------------------------------------------------------------------- /src/windows/LabelButtonBackground.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 使用QSS为标签和按钮添加背景图 4 | 5 | ''' 6 | 7 | from PyQt5.QtWidgets import * 8 | import sys 9 | 10 | class LabelButtonBackground(QWidget): 11 | def __init__(self): 12 | super().__init__() 13 | label1 = QLabel(self) 14 | label1.setToolTip('这是一个文本标签') 15 | label1.setStyleSheet('QLabel{border-image:url(./images/python.jpg);}') 16 | 17 | label1.setFixedWidth(476) 18 | label1.setFixedHeight(259) 19 | 20 | btn1 = QPushButton(self) 21 | btn1.setObjectName('btn1') 22 | btn1.setMaximumSize(48,48) 23 | btn1.setMinimumSize(48,48) 24 | 25 | style = ''' 26 | 27 | #btn1{ 28 | border-radius:4px; 29 | background-image:url('./images/add.png'); 30 | } 31 | #btn1:Pressed { 32 | background-image:url('./images/addhover.png'); 33 | } 34 | ''' 35 | btn1.setStyleSheet(style) 36 | 37 | vbox = QVBoxLayout() 38 | vbox.addWidget(label1) 39 | vbox.addStretch() 40 | vbox.addWidget(btn1) 41 | 42 | self.setLayout(vbox) 43 | self.setWindowTitle('使用QSS为标签和按钮添加背景图') 44 | 45 | 46 | if __name__ == "__main__": 47 | app = QApplication(sys.argv) 48 | form = LabelButtonBackground() 49 | form.show() 50 | sys.exit(app.exec_()) 51 | -------------------------------------------------------------------------------- /src/table_tree/TreeEvent.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 为树节点添加响应事件 4 | 5 | ''' 6 | from PyQt5.QtWidgets import * 7 | from PyQt5.QtCore import * 8 | import sys 9 | 10 | 11 | class TreeEvent(QMainWindow): 12 | def __init__(self, parent=None): 13 | super(TreeEvent, self).__init__(parent) 14 | self.setWindowTitle('为树节点添加响应事件') 15 | 16 | self.tree = QTreeWidget() 17 | 18 | self.tree.setColumnCount(2) 19 | 20 | self.tree.setHeaderLabels(['Key','Value']) 21 | 22 | root = QTreeWidgetItem(self.tree) 23 | root.setText(0,'root') 24 | root.setText(1, '0') 25 | 26 | child1 = QTreeWidgetItem(root) 27 | child1.setText(0,'child1') 28 | child1.setText(1,'1') 29 | 30 | child2 = QTreeWidgetItem(root) 31 | child2.setText(0,'child2') 32 | child2.setText(1,'2') 33 | 34 | child3 = QTreeWidgetItem(child2) 35 | child3.setText(0,'child3') 36 | child3.setText(1,'3') 37 | self.tree.clicked.connect(self.onTreeClicked) 38 | self.setCentralWidget(self.tree) 39 | def onTreeClicked(self,index): 40 | item = self.tree.currentItem() 41 | print(index.row()) 42 | print('key=%s,value=%s' % (item.text(0),item.text(1))) 43 | 44 | if __name__ == '__main__': 45 | app = QApplication(sys.argv) 46 | tree = TreeEvent() 47 | tree.show() 48 | sys.exit(app.exec_()) 49 | -------------------------------------------------------------------------------- /src/layout/Stretch1.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 设置伸缩量(addStretch) 4 | 5 | 6 | 7 | ''' 8 | 9 | import sys,math 10 | from PyQt5.QtWidgets import * 11 | 12 | 13 | class Stretch(QWidget) : 14 | def __init__(self): 15 | super(Stretch,self).__init__() 16 | self.setWindowTitle("设置伸缩量") 17 | self.resize(800,100) 18 | btn1 = QPushButton(self) 19 | btn2 = QPushButton(self) 20 | btn3 = QPushButton(self) 21 | btn4 = QPushButton(self) 22 | btn5 = QPushButton(self) 23 | btn1.setText("按钮1") 24 | btn2.setText("按钮2") 25 | btn3.setText("按钮3") 26 | btn4.setText("按钮4") 27 | btn5.setText("按钮5") 28 | 29 | layout = QHBoxLayout() 30 | 31 | layout.addStretch(0) 32 | layout.addWidget(btn1) 33 | layout.addWidget(btn2) 34 | layout.addWidget(btn3) 35 | layout.addWidget(btn4) 36 | layout.addWidget(btn5) 37 | 38 | btnOK = QPushButton(self) 39 | btnOK.setText("确定") 40 | btnCancel = QPushButton(self) 41 | btnCancel.setText("取消") 42 | layout.addStretch(1) 43 | 44 | layout.addWidget(btnOK) 45 | layout.addWidget(btnCancel) 46 | self.setLayout(layout) 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | if __name__ == '__main__': 55 | app = QApplication(sys.argv) 56 | main = Stretch() 57 | main.show() 58 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/QSSSelector.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 使用QSS选择器设置控件样式 4 | 5 | ''' 6 | 7 | from PyQt5.QtWidgets import * 8 | import sys 9 | import qdarkstyle 10 | class QSSSelector(QWidget): 11 | def __init__(self): 12 | super().__init__() 13 | self.setWindowTitle("QSS样式") 14 | btn1 = QPushButton(self) 15 | btn1.setText("按钮1") 16 | btn2 = QPushButton(self) 17 | btn2.setProperty('name','btn2') 18 | btn2.setText("按钮2") 19 | 20 | btn3 = QPushButton(self) 21 | btn3.setProperty('name','btn3') 22 | btn3.setText("按钮3") 23 | 24 | vbox = QVBoxLayout() 25 | vbox.addWidget(btn1) 26 | vbox.addWidget(btn2) 27 | vbox.addWidget(btn3) 28 | 29 | self.setLayout(vbox) 30 | if __name__ == "__main__": 31 | app = QApplication(sys.argv) 32 | form = QSSSelector() 33 | # 选择器 34 | qssStyle = ''' 35 | QPushButton[name="btn2"] { 36 | background-color:red; 37 | color:yellow; 38 | height:120; 39 | font-size:60px; 40 | } 41 | QPushButton[name="btn3"] { 42 | background-color:blue; 43 | color:yellow; 44 | height:60; 45 | font-size:30px; 46 | } 47 | ''' 48 | #form.setStyleSheet(qssStyle) 49 | form.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) 50 | form.show() 51 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/controls/QComboBoxDemo.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 下拉列表控件(QComboBox) 4 | 5 | 1. 如果将列表项添加到QComboBox控件中 6 | 7 | 2. 如何获取选中的列表项 8 | 9 | ''' 10 | 11 | import sys 12 | from PyQt5.QtCore import * 13 | from PyQt5.QtGui import * 14 | from PyQt5.QtWidgets import * 15 | 16 | class QComboBoxDemo(QWidget): 17 | def __init__(self): 18 | super(QComboBoxDemo,self).__init__() 19 | self.initUI() 20 | 21 | def initUI(self): 22 | self.setWindowTitle('下拉列表控件演示') 23 | self.resize(300,100) 24 | 25 | layout = QVBoxLayout() 26 | 27 | self.label = QLabel('请选择编程语言') 28 | 29 | self.cb = QComboBox() 30 | self.cb.addItem('C++') 31 | self.cb.addItem('Python') 32 | self.cb.addItems(['Java','C#','Ruby']) 33 | 34 | self.cb.currentIndexChanged.connect(self.selectionChange) 35 | 36 | layout.addWidget(self.label) 37 | layout.addWidget(self.cb) 38 | 39 | self.setLayout(layout) 40 | 41 | def selectionChange(self,i): 42 | self.label.setText(self.cb.currentText()) 43 | self.label.adjustSize() 44 | 45 | for count in range(self.cb.count()): 46 | print('item' + str(count) + '=' + self.cb.itemText(count)) 47 | 48 | print('current index',i,'selection changed', self.cb.currentText()) 49 | 50 | if __name__ == '__main__': 51 | app = QApplication(sys.argv) 52 | main = QComboBoxDemo() 53 | main.show() 54 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/containers/MultiWindows.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 容纳多文档的窗口 4 | 5 | QMdiArea 6 | 7 | QMdiSubWindow 8 | 9 | ''' 10 | 11 | import sys 12 | from PyQt5.QtCore import * 13 | from PyQt5.QtGui import * 14 | from PyQt5.QtWidgets import * 15 | 16 | 17 | class MultiWindows(QMainWindow): 18 | count = 0 19 | 20 | def __init__(self, parent=None): 21 | super(MultiWindows, self).__init__(parent) 22 | 23 | self.setWindowTitle("容纳多文档的窗口") 24 | 25 | self.mdi = QMdiArea() 26 | self.setCentralWidget(self.mdi) 27 | bar = self.menuBar() 28 | file = bar.addMenu("File") 29 | file.addAction("New") 30 | file.addAction("cascade") 31 | file.addAction("Tiled") 32 | 33 | file.triggered.connect(self.windowaction) 34 | def windowaction(self,q): 35 | print(q.text()) 36 | if q.text() == "New": 37 | MultiWindows.count = MultiWindows.count + 1 38 | sub = QMdiSubWindow() 39 | sub.setWidget(QTextEdit()) 40 | sub.setWindowTitle("子窗口" + str(MultiWindows.count)) 41 | self.mdi.addSubWindow(sub) 42 | sub.show() 43 | elif q.text() == "cascade": 44 | self.mdi.cascadeSubWindows() 45 | elif q.text() == "Tiled": 46 | self.mdi.tileSubWindows() 47 | 48 | 49 | 50 | if __name__ == '__main__': 51 | app = QApplication(sys.argv) 52 | demo = MultiWindows() 53 | demo.show() 54 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/menu_toolbar_statusbar/Toolbar.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 创建和使用工具栏 4 | 5 | 工具栏默认按钮:只显示图标,将文本作为悬停提示展示 6 | 7 | 工具栏按钮有3中显示状态 8 | 9 | 1. 只显示图标 10 | 2. 只显示文本 11 | 3. 同时显示文本和图标 12 | ''' 13 | 14 | import sys,math 15 | from PyQt5.QtWidgets import * 16 | from PyQt5.QtGui import * 17 | from PyQt5.QtCore import * 18 | 19 | class Toolbar(QMainWindow) : 20 | def __init__(self): 21 | super(Toolbar,self).__init__() 22 | self.initUI() 23 | def initUI(self): 24 | self.setWindowTitle("工具栏例子") 25 | self.resize(300,200) 26 | 27 | tb1 = self.addToolBar("File") 28 | 29 | new = QAction(QIcon('./images/new.png'),"new",self) 30 | tb1.addAction(new) 31 | 32 | open = QAction(QIcon('./images/open.png'),"open",self) 33 | tb1.addAction(open) 34 | 35 | save = QAction(QIcon('./images/save.png'),"save",self) 36 | tb1.addAction(save) 37 | 38 | 39 | tb2 = self.addToolBar("File1") 40 | new1 = QAction(QIcon('./images/new.png'),"新建",self) 41 | tb2.addAction(new1) 42 | 43 | tb2.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) 44 | 45 | tb1.actionTriggered.connect(self.toolbtnpressed) 46 | 47 | tb2.actionTriggered.connect(self.toolbtnpressed) 48 | def toolbtnpressed(self,a): 49 | print("按下的工具栏按钮是",a.text()) 50 | 51 | 52 | if __name__ == '__main__': 53 | app = QApplication(sys.argv) 54 | main = Toolbar() 55 | main.show() 56 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/table_tree/TableView.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 显示二维表数据(QTableView控件) 4 | 5 | 数据源 6 | 7 | Model 8 | 9 | 需要创建QTableView实例和一个数据源(Model),然后将两者关联 10 | 11 | MVC:Model Viewer Controller 12 | 13 | MVC的目的是将后端的数据和前端页面的耦合度降低 14 | 15 | 16 | 17 | ''' 18 | from PyQt5.QtWidgets import * 19 | from PyQt5.QtGui import * 20 | import sys 21 | 22 | class TableView(QWidget): 23 | 24 | def __init__(self, arg=None): 25 | super(TableView, self).__init__(arg) 26 | self.setWindowTitle("QTableView表格视图控件演示") 27 | self.resize(500,300); 28 | 29 | self.model = QStandardItemModel(4,3) 30 | self.model.setHorizontalHeaderLabels(['id','姓名','年龄']) 31 | 32 | self.tableview = QTableView() 33 | # 关联QTableView控件和Model 34 | self.tableview.setModel(self.model) 35 | 36 | # 添加数据 37 | item11 = QStandardItem('10') 38 | item12 = QStandardItem('雷神') 39 | item13 = QStandardItem('2000') 40 | self.model.setItem(0,0,item11) 41 | self.model.setItem(0,1, item12) 42 | self.model.setItem(0,2, item13) 43 | 44 | item31 = QStandardItem('30') 45 | item32 = QStandardItem('死亡女神') 46 | item33 = QStandardItem('3000') 47 | self.model.setItem(2,0,item31) 48 | self.model.setItem(2,1, item32) 49 | self.model.setItem(2,2, item33) 50 | 51 | layout = QVBoxLayout() 52 | layout.addWidget(self.tableview) 53 | self.setLayout(layout) 54 | 55 | 56 | 57 | 58 | if __name__ == '__main__': 59 | app = QApplication(sys.argv) 60 | table = TableView() 61 | table.show() 62 | sys.exit(app.exec_()) 63 | -------------------------------------------------------------------------------- /src/windows/AnimWindow.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 用动画效果改变窗口尺寸 4 | 5 | 6 | QPropertyAnimation 7 | 8 | 9 | 10 | 11 | ''' 12 | 13 | from PyQt5.QtGui import * 14 | from PyQt5.QtCore import * 15 | from PyQt5.QtWidgets import * 16 | import sys 17 | 18 | 19 | class AnimWindow(QWidget): 20 | def __init__(self): 21 | super(AnimWindow, self).__init__() 22 | self.OrigHeight = 50 23 | self.ChangeHeight = 150 24 | self.setGeometry(QRect(500, 400, 150, self.OrigHeight)) 25 | self.btn = QPushButton('展开', self) 26 | self.btn.setGeometry(10, 10, 60, 35) 27 | self.btn.clicked.connect(self.change) 28 | def change(self): 29 | currentHeight = self.height() 30 | if self.OrigHeight == currentHeight: 31 | startHeight = self.OrigHeight 32 | endHeight = self.ChangeHeight 33 | self.btn.setText('收缩') 34 | else: 35 | startHeight = self.ChangeHeight 36 | endHeight= self.OrigHeight 37 | self.btn.setText('展开') 38 | 39 | self.animation = QPropertyAnimation(self,b'geometry') 40 | self.animation.setDuration(500) 41 | self.animation.setStartValue(QRect(500,400,150,startHeight)) 42 | self.animation.setEndValue(QRect(500,400,150,endHeight)) 43 | self.animation.start() 44 | 45 | 46 | 47 | if __name__ == '__main__': 48 | app = QApplication(sys.argv) 49 | window = AnimWindow() 50 | window.show() 51 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/designer/MainWinMaxMinSize.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 180 21 | 90 22 | 300 23 | 300 24 | 25 | 26 | 27 | 28 | 100 29 | 100 30 | 31 | 32 | 33 | 34 | 300 35 | 300 36 | 37 | 38 | 39 | PushButton 40 | 41 | 42 | 43 | 44 | 45 | 46 | 0 47 | 0 48 | 800 49 | 22 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/table_tree/CellImageSize.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 改变单元格中图片的尺寸 4 | 5 | setIconSize(QSize(width,height)) 6 | 7 | ''' 8 | 9 | import sys 10 | from PyQt5.QtWidgets import * 11 | from PyQt5.QtGui import * 12 | from PyQt5.QtCore import * 13 | 14 | 15 | class CellImageSize(QWidget): 16 | def __init__(self): 17 | super(CellImageSize,self).__init__() 18 | self.initUI() 19 | 20 | def initUI(self): 21 | self.setWindowTitle("改变单元格中图片的尺寸") 22 | self.resize(1000, 900); 23 | layout = QHBoxLayout() 24 | 25 | tablewidget = QTableWidget() 26 | tablewidget.setIconSize(QSize(300,200)) 27 | tablewidget.setColumnCount(3) 28 | tablewidget.setRowCount(5) 29 | 30 | tablewidget.setHorizontalHeaderLabels(['图片1', '图片2', '图片3']) 31 | 32 | # 让列的宽度和图片的宽度相同 33 | for i in range(3): 34 | tablewidget.setColumnWidth(i,300) 35 | 36 | # 让行的高度和图片的高度相同 37 | for i in range(15): 38 | tablewidget.setRowHeight(i,200) 39 | 40 | for k in range(15): 41 | i = k / 3 # 行 42 | j = k % 3 # 列 43 | item = QTableWidgetItem() 44 | 45 | item.setIcon(QIcon('./images/bao%d.png' % k)) 46 | tablewidget.setItem(i,j,item) 47 | 48 | 49 | layout.addWidget(tablewidget) 50 | 51 | self.setLayout(layout) 52 | 53 | 54 | if __name__ == '__main__': 55 | app = QApplication(sys.argv) 56 | example = CellImageSize() 57 | example.show() 58 | sys.exit(app.exec_()) 59 | -------------------------------------------------------------------------------- /src/table_tree/CellTextAlignment.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 设置单元格的文本对齐方式 4 | 5 | setTextAlignment 6 | 7 | Qt.AlignRight Qt.AlignBottom 8 | 9 | ''' 10 | 11 | import sys 12 | from PyQt5.QtWidgets import (QWidget, QTableWidget, QHBoxLayout, QApplication, QTableWidgetItem) 13 | from PyQt5.QtCore import Qt 14 | 15 | 16 | class CellTextAlignment(QWidget): 17 | def __init__(self): 18 | super(CellTextAlignment,self).__init__() 19 | self.initUI() 20 | 21 | def initUI(self): 22 | self.setWindowTitle("设置单元格的文本对齐方式") 23 | self.resize(430, 230); 24 | layout = QHBoxLayout() 25 | tableWidget = QTableWidget() 26 | tableWidget.setRowCount(4) 27 | tableWidget.setColumnCount(3) 28 | layout.addWidget(tableWidget) 29 | 30 | tableWidget.setHorizontalHeaderLabels(['姓名', '性别', '体重(kg)']) 31 | 32 | newItem = QTableWidgetItem('雷神') 33 | newItem.setTextAlignment(Qt.AlignRight | Qt.AlignBottom) 34 | tableWidget.setItem(0,0,newItem) 35 | 36 | newItem = QTableWidgetItem('男') 37 | newItem.setTextAlignment(Qt.AlignCenter | Qt.AlignBottom) 38 | tableWidget.setItem(0,1,newItem) 39 | 40 | newItem = QTableWidgetItem('190') 41 | newItem.setTextAlignment(Qt.AlignRight) 42 | tableWidget.setItem(0,2,newItem) 43 | 44 | self.setLayout(layout) 45 | 46 | 47 | if __name__ == '__main__': 48 | app = QApplication(sys.argv) 49 | example = CellTextAlignment() 50 | example.show() 51 | sys.exit(app.exec_()) 52 | -------------------------------------------------------------------------------- /src/drawing/DrawMultiLine.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 绘制不同类型的直线 4 | 5 | 6 | 7 | ''' 8 | 9 | import sys,math 10 | from PyQt5.QtWidgets import * 11 | from PyQt5.QtGui import * 12 | from PyQt5.QtCore import Qt 13 | 14 | class DrawMultiLine(QWidget): 15 | def __init__(self): 16 | super(DrawMultiLine,self).__init__() 17 | self.resize(300,300) 18 | self.setWindowTitle('设置Pen的样式') 19 | 20 | def paintEvent(self, event): 21 | painter = QPainter() 22 | painter.begin(self) 23 | 24 | 25 | pen = QPen(Qt.red,3,Qt.SolidLine) 26 | 27 | painter.setPen(pen) 28 | painter.drawLine(20,40,250,40) 29 | 30 | pen.setStyle(Qt.DashLine) 31 | painter.setPen(pen) 32 | painter.drawLine(20, 80, 250, 80) 33 | 34 | pen.setStyle(Qt.DashDotDotLine) 35 | painter.setPen(pen) 36 | painter.drawLine(20, 120, 250, 120) 37 | 38 | pen.setStyle(Qt.DotLine) 39 | painter.setPen(pen) 40 | painter.drawLine(20, 160, 250, 160) 41 | 42 | pen.setStyle(Qt.DashDotDotLine) 43 | painter.setPen(pen) 44 | painter.drawLine(20, 200, 250, 200) 45 | 46 | pen.setStyle(Qt.CustomDashLine) 47 | pen.setDashPattern([1,10,5,8]) 48 | painter.setPen(pen) 49 | painter.drawLine(20, 240, 250, 240) 50 | 51 | 52 | size = self.size() 53 | 54 | 55 | 56 | painter.end() 57 | if __name__ == '__main__': 58 | app = QApplication(sys.argv) 59 | main = DrawMultiLine() 60 | main.show() 61 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/SignalSlot/MultiWindow1.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 多窗口交互(1):不使用信号与槽 4 | 5 | Win1 6 | 7 | Win2 8 | 9 | ''' 10 | 11 | import sys 12 | from PyQt5.QtCore import * 13 | from PyQt5.QtGui import * 14 | from PyQt5.QtWidgets import * 15 | from DateDialog import DateDialog 16 | 17 | class MultiWindow1(QWidget): 18 | def __init__(self): 19 | super().__init__() 20 | self.setWindowTitle("多窗口交互(1):不使用信号与槽") 21 | 22 | self.lineEdit = QLineEdit(self) 23 | self.button1 = QPushButton('弹出对话框1') 24 | self.button1.clicked.connect(self.onButton1Click) 25 | 26 | self.button2 = QPushButton('弹出对话框2') 27 | self.button2.clicked.connect(self.onButton2Click) 28 | 29 | gridLayout = QGridLayout() 30 | gridLayout.addWidget(self.lineEdit) 31 | gridLayout.addWidget(self.button1) 32 | gridLayout.addWidget(self.button2) 33 | 34 | self.setLayout(gridLayout) 35 | 36 | def onButton1Click(self): 37 | dialog = DateDialog(self) 38 | result = dialog.exec() 39 | date = dialog.dateTime() 40 | self.lineEdit.setText(date.date().toString()) 41 | dialog.destroy() 42 | 43 | def onButton2Click(self): 44 | date,time,result = DateDialog.getDateTime() 45 | self.lineEdit.setText(date.toString()) 46 | if result == QDialog.Accepted: 47 | print('点击确定按钮') 48 | else: 49 | print('单击取消按钮') 50 | if __name__ == "__main__": 51 | app = QApplication(sys.argv) 52 | form = MultiWindow1() 53 | form.show() 54 | sys.exit(app.exec_()) 55 | -------------------------------------------------------------------------------- /src/windows/WindowMaxMin.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 用代码控制窗口的最大化和最小化 3 | 4 | ''' 5 | 6 | 7 | import sys 8 | from PyQt5.QtWidgets import * 9 | from PyQt5.QtCore import * 10 | 11 | 12 | ### 自定义窗口类 13 | class WindowMaxMin(QWidget): 14 | 15 | 16 | ### 构造函数 17 | def __init__(self, parent=None): 18 | '''构造函数''' 19 | # 调用父类构造函数 20 | super(WindowMaxMin, self).__init__(parent) 21 | self.resize(300,400) 22 | self.setWindowTitle("用代码控制窗口的最大化和最小化") 23 | self.setWindowFlags(Qt.WindowMaximizeButtonHint) 24 | 25 | layout = QVBoxLayout() 26 | maxButton1 = QPushButton() 27 | maxButton1.setText('窗口最大化1') 28 | maxButton1.clicked.connect(self.maximized1) 29 | 30 | 31 | maxButton2 = QPushButton() 32 | maxButton2.setText('窗口最大化2') 33 | maxButton2.clicked.connect(self.showMaximized) 34 | 35 | minButton = QPushButton() 36 | minButton.setText('窗口最小化') 37 | minButton.clicked.connect(self.showMinimized) 38 | 39 | 40 | layout.addWidget(maxButton1) 41 | layout.addWidget(maxButton2) 42 | layout.addWidget(minButton) 43 | self.setLayout(layout) 44 | 45 | 46 | 47 | def maximized1(self): 48 | desktop = QApplication.desktop() 49 | # 获取桌面可用尺寸 50 | rect = desktop.availableGeometry() 51 | 52 | self.setGeometry(rect) 53 | 54 | 55 | 56 | if __name__ == "__main__": 57 | 58 | app = QApplication(sys.argv) 59 | 60 | window = WindowMaxMin() 61 | window.show() 62 | # 应用程序事件循环 63 | sys.exit(app.exec_()) 64 | -------------------------------------------------------------------------------- /src/controls/ScreenGeometry.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QHBoxLayout,QMainWindow,QApplication,QPushButton,QWidget 3 | def onClick_Button(): 4 | print("1") 5 | print("widget.x() = %d" % widget.x()) # 250 (窗口横坐标) 6 | print("widget.y() = %d" % widget.y()) # 200 (窗口纵坐标) 7 | print("widget.width() = %d" % widget.width()) # 300(工作区宽度) 8 | print("widget.height() = %d" % widget.height()) # 240 (工作区高度) 9 | 10 | print("2") 11 | print("widget.geometry().x() = %d" % widget.geometry().x()) # 250 (工作区横坐标) 12 | print("widget.geometry().y() = %d" % widget.geometry().y()) # 222 (工作区纵坐标) 13 | print("widget.geometry().width() = %d" % widget.geometry().width() ) # 300(工作区宽度) 14 | print("widget.geometry().height() = %d" % widget.geometry().height()) # 240 (工作区高度) 15 | 16 | print("3") 17 | print("widget.frameGeometry().x() = %d" % widget.frameGeometry().x()) # 250 (窗口横坐标) 18 | print("widget.frameGeometry().y() = %d" % widget.frameGeometry().y()) # 200 (窗口纵坐标) 19 | print("widget.frameGeometry().width() = %d" % widget.frameGeometry().width() ) # 300(窗口宽度) 20 | print("widget.frameGeometry().height() = %d" % widget.frameGeometry().height()) # 262(窗口高度) 21 | 22 | app = QApplication(sys.argv) 23 | 24 | widget = QWidget() 25 | btn = QPushButton(widget) 26 | btn.setText("按钮") 27 | btn.clicked.connect(onClick_Button) 28 | 29 | btn.move(24,52) 30 | 31 | widget.resize(300,240) # 设置工作区的尺寸 32 | 33 | widget.move(250,200) 34 | 35 | widget.setWindowTitle('屏幕坐标系') 36 | 37 | widget.show() 38 | 39 | sys.exit(app.exec_()) 40 | 41 | -------------------------------------------------------------------------------- /src/dialogs/QColorDialog.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 颜色对话框:QColorDialog 4 | 5 | ''' 6 | 7 | ''' 8 | 9 | 字体对话框:QFontDialog 10 | 11 | 12 | 13 | ''' 14 | 15 | import sys 16 | from PyQt5.QtCore import * 17 | from PyQt5.QtGui import * 18 | from PyQt5.QtWidgets import * 19 | class QColorDialogDemo(QWidget): 20 | def __init__(self): 21 | super(QColorDialogDemo,self).__init__() 22 | self.initUI() 23 | 24 | def initUI(self): 25 | self.setWindowTitle('Color Dialog例子') 26 | layout = QVBoxLayout() 27 | self.colorButton = QPushButton('设置颜色') 28 | self.colorButton.clicked.connect(self.getColor) 29 | layout.addWidget(self.colorButton) 30 | 31 | self.colorButton1 = QPushButton('设置背景颜色') 32 | self.colorButton1.clicked.connect(self.getBGColor) 33 | layout.addWidget(self.colorButton1) 34 | 35 | self.colorLabel = QLabel('Hello,测试颜色例子') 36 | layout.addWidget(self.colorLabel) 37 | 38 | self.setLayout(layout) 39 | def getColor(self): 40 | color = QColorDialog.getColor() 41 | p = QPalette() 42 | p.setColor(QPalette.WindowText,color) 43 | self.colorLabel.setPalette(p) 44 | def getBGColor(self): 45 | color = QColorDialog.getColor() 46 | p = QPalette() 47 | p.setColor(QPalette.Window,color) 48 | self.colorLabel.setAutoFillBackground(True) 49 | self.colorLabel.setPalette(p) 50 | 51 | if __name__ == '__main__': 52 | app = QApplication(sys.argv) 53 | main = QColorDialogDemo() 54 | main.show() 55 | sys.exit(app.exec_()) 56 | 57 | -------------------------------------------------------------------------------- /src/project/CallWeatherWin.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 项目实战:天气信息查询 3 | 4 | ''' 5 | 6 | import sys 7 | from PyQt5.QtWidgets import QApplication , QMainWindow 8 | from WeatherWin import Ui_Form 9 | import requests 10 | 11 | class MainWindow(QMainWindow ): 12 | def __init__(self, parent=None): 13 | super(MainWindow, self).__init__(parent) 14 | self.ui = Ui_Form() 15 | self.ui.setupUi(self) 16 | 17 | def queryWeather(self): 18 | cityName = self.ui.weatherComboBox.currentText() 19 | cityCode = self.transCityName(cityName) 20 | 21 | rep = requests.get('http://www.weather.com.cn/data/sk/' + cityCode + '.html') 22 | rep.encoding = 'utf-8' 23 | print( rep.json() ) 24 | 25 | msg1 = '城市: %s' % rep.json()['weatherinfo']['city'] + '\n' 26 | msg2 = '风向: %s' % rep.json()['weatherinfo']['WD'] + '\n' 27 | msg3 = '温度: %s' % rep.json()['weatherinfo']['temp'] + ' 度' + '\n' 28 | msg4 = '风力: %s' % rep.json()['weatherinfo']['WS'] + '\n' 29 | msg5 = '湿度: %s' % rep.json()['weatherinfo']['SD'] + '\n' 30 | result = msg1 + msg2 + msg3 + msg4 + msg5 31 | self.ui.resultText.setText(result) 32 | 33 | def transCityName(self ,cityName): 34 | cityCode = '' 35 | if cityName == '北京' : 36 | cityCode = '101010100' 37 | elif cityName == '天津' : 38 | cityCode = '101030100' 39 | elif cityName == '上海' : 40 | cityCode = '101020100' 41 | 42 | return cityCode 43 | 44 | def clearResult(self): 45 | print('* clearResult ') 46 | self.ui.resultText.clear() 47 | 48 | if __name__=="__main__": 49 | app = QApplication(sys.argv) 50 | win = MainWindow() 51 | win.show() 52 | sys.exit(app.exec_()) 53 | -------------------------------------------------------------------------------- /src/table_tree/DataLocation.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 在表格中快速定位到特定的行 4 | 5 | 1. 数据的定位:findItems 返回一个列表 6 | 2. 如果找到了满足条件的单元格,会定位到单元格所在的行:setSliderPosition(row) 7 | 8 | ''' 9 | 10 | import sys 11 | from PyQt5.QtWidgets import * 12 | from PyQt5 import QtCore 13 | from PyQt5.QtGui import QColor, QBrush 14 | 15 | 16 | class DataLocation(QWidget): 17 | def __init__(self): 18 | super(DataLocation,self).__init__() 19 | self.initUI() 20 | 21 | def initUI(self): 22 | self.setWindowTitle("QTableWidget 例子") 23 | self.resize(600, 800); 24 | 25 | layout = QHBoxLayout() 26 | tableWidget = QTableWidget() 27 | tableWidget.setRowCount(40) 28 | tableWidget.setColumnCount(4) 29 | 30 | layout.addWidget(tableWidget) 31 | 32 | for i in range(40): 33 | for j in range(4): 34 | itemContent = '(%d,%d)' %(i,j) 35 | tableWidget.setItem(i,j,QTableWidgetItem(itemContent)) 36 | self.setLayout(layout) 37 | 38 | # 搜索满足条件的Cell 39 | text = '(1' 40 | items = tableWidget.findItems(text,QtCore.Qt.MatchStartsWith) 41 | if len(items) > 0: 42 | item = items[0] 43 | item.setBackground(QBrush(QColor(0,255,0))) 44 | item.setForeground(QBrush(QColor(255,0,0))) 45 | 46 | row = item.row() 47 | 48 | # 定位到指定的行 49 | tableWidget.verticalScrollBar().setSliderPosition(row) 50 | 51 | if __name__ == '__main__': 52 | app = QApplication(sys.argv) 53 | example = DataLocation() 54 | example.show() 55 | sys.exit(app.exec_()) 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/table_tree/CellFontAndColor.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 设置单元格字体和颜色 3 | 4 | 5 | 6 | ''' 7 | 8 | import sys 9 | from PyQt5.QtWidgets import (QWidget, QTableWidget, QHBoxLayout, QApplication, QTableWidgetItem) 10 | from PyQt5.QtGui import QBrush, QColor, QFont 11 | 12 | 13 | class CellFontAndColor(QWidget): 14 | def __init__(self): 15 | super(CellFontAndColor,self).__init__() 16 | self.initUI() 17 | 18 | def initUI(self): 19 | self.setWindowTitle("设置单元格字体和颜色") 20 | self.resize(430, 230); 21 | layout = QHBoxLayout() 22 | tableWidget = QTableWidget() 23 | tableWidget.setRowCount(4) 24 | tableWidget.setColumnCount(3) 25 | layout.addWidget(tableWidget) 26 | 27 | tableWidget.setHorizontalHeaderLabels(['姓名', '性别', '体重(kg)']) 28 | 29 | newItem = QTableWidgetItem('雷神') 30 | newItem.setFont(QFont('Times',14,QFont.Black)) 31 | newItem.setForeground(QBrush(QColor(255,0,0))) 32 | tableWidget.setItem(0,0,newItem) 33 | 34 | newItem = QTableWidgetItem('女') 35 | newItem.setForeground(QBrush(QColor(255,255,0))) 36 | newItem.setBackground(QBrush(QColor(0,0,255))) 37 | tableWidget.setItem(0,1,newItem) 38 | 39 | newItem = QTableWidgetItem('160') 40 | newItem.setFont(QFont('Times',20,QFont.Black)) 41 | newItem.setForeground(QBrush(QColor(0,0,255))) 42 | tableWidget.setItem(0,2,newItem) 43 | 44 | self.setLayout(layout) 45 | 46 | 47 | if __name__ == '__main__': 48 | app = QApplication(sys.argv) 49 | example = CellFontAndColor() 50 | example.show() 51 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/ext/pyqtgraph_pyqt.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 10 21 | 10 22 | 721 23 | 251 24 | 25 | 26 | 27 | 28 | 29 | 30 | 10 31 | 290 32 | 501 33 | 281 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 0 42 | 0 43 | 800 44 | 22 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | GraphicsLayoutWidget 53 | QWidget 54 |
pyqtgraph
55 | 1 56 |
57 |
58 | 59 | 60 |
61 | -------------------------------------------------------------------------------- /src/table_tree/CellSize.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 设置单元格尺寸 4 | 5 | ''' 6 | 7 | import sys 8 | from PyQt5.QtWidgets import * 9 | from PyQt5.QtGui import QBrush, QColor, QFont 10 | 11 | class CellSize(QWidget): 12 | def __init__(self): 13 | super(CellSize,self).__init__() 14 | self.initUI() 15 | 16 | def initUI(self): 17 | self.setWindowTitle("QTableWidget 例子") 18 | self.resize(530, 300); 19 | layout = QHBoxLayout() 20 | tableWidget = QTableWidget() 21 | tableWidget.setRowCount(4) 22 | tableWidget.setColumnCount(3) 23 | layout.addWidget(tableWidget) 24 | 25 | tableWidget.setHorizontalHeaderLabels(['姓名', '性别', '体重(kg)']) 26 | tableWidget.setRowHeight(0, 80) 27 | tableWidget.setColumnWidth(2, 120) 28 | tableWidget.setRowHeight(2,100) 29 | newItem = QTableWidgetItem('雷神') 30 | newItem.setFont(QFont('Times',40,QFont.Black)) 31 | newItem.setForeground(QBrush(QColor(255,0,0))) 32 | tableWidget.setItem(0,0,newItem) 33 | 34 | newItem = QTableWidgetItem('女') 35 | newItem.setForeground(QBrush(QColor(255,255,0))) 36 | newItem.setBackground(QBrush(QColor(0,0,255))) 37 | tableWidget.setItem(0,1,newItem) 38 | 39 | newItem = QTableWidgetItem('160') 40 | newItem.setFont(QFont('Times',60,QFont.Black)) 41 | newItem.setForeground(QBrush(QColor(0,0,255))) 42 | tableWidget.setItem(0,2,newItem) 43 | 44 | self.setLayout(layout) 45 | 46 | 47 | if __name__ == '__main__': 48 | app = QApplication(sys.argv) 49 | example = CellSize() 50 | example.show() 51 | sys.exit(app.exec_()) 52 | -------------------------------------------------------------------------------- /src/table_tree/PlaceControlInCell.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 在单元格中放置控件 4 | 5 | setItem:将文本放到单元格中 6 | setCellWidget:将控件放到单元格中 7 | setStyleSheet:设置控件的样式(QSS) 8 | 9 | ''' 10 | 11 | import sys 12 | from PyQt5.QtWidgets import (QWidget, QTableWidget, QHBoxLayout, QApplication, QTableWidgetItem, QAbstractItemView, 13 | QComboBox, QPushButton) 14 | 15 | 16 | class PlaceControlInCell(QWidget): 17 | def __init__(self): 18 | super(PlaceControlInCell,self).__init__() 19 | self.initUI() 20 | 21 | def initUI(self): 22 | self.setWindowTitle("在单元格中放置控件") 23 | self.resize(430, 300); 24 | layout = QHBoxLayout() 25 | tableWidget = QTableWidget() 26 | tableWidget.setRowCount(4) 27 | tableWidget.setColumnCount(3) 28 | 29 | layout.addWidget(tableWidget) 30 | 31 | tableWidget.setHorizontalHeaderLabels(['姓名','性别','体重(kg)']) 32 | textItem = QTableWidgetItem('小明') 33 | tableWidget.setItem(0,0,textItem) 34 | 35 | combox = QComboBox() 36 | combox.addItem('男') 37 | combox.addItem('女') 38 | # QSS Qt StyleSheet 39 | combox.setStyleSheet('QComboBox{margin:3px};') 40 | tableWidget.setCellWidget(0,1,combox) 41 | 42 | modifyButton = QPushButton('修改') 43 | modifyButton.setDown(True) 44 | modifyButton.setStyleSheet('QPushButton{margin:3px};') 45 | tableWidget.setCellWidget(0,2,modifyButton) 46 | 47 | self.setLayout(layout) 48 | 49 | 50 | 51 | if __name__ == '__main__': 52 | app = QApplication(sys.argv) 53 | example = PlaceControlInCell() 54 | example.show() 55 | sys.exit(app.exec_()) 56 | -------------------------------------------------------------------------------- /src/table_tree/BasicTreeWidget.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 树控件(QTreeWidget)的基本用法 4 | 5 | 6 | 7 | ''' 8 | 9 | import sys 10 | from PyQt5.QtWidgets import * 11 | from PyQt5.QtGui import QIcon, QBrush, QColor 12 | from PyQt5.QtCore import Qt 13 | 14 | 15 | class BasicTreeWidget(QMainWindow): 16 | def __init__(self, parent=None): 17 | super(BasicTreeWidget, self).__init__(parent) 18 | self.setWindowTitle('树控件(QTreeWidget)的基本用法') 19 | 20 | self.tree = QTreeWidget() 21 | # 为树控件指定列数 22 | self.tree.setColumnCount(2) 23 | 24 | # 指定列标签 25 | self.tree.setHeaderLabels(['Key','Value']) 26 | 27 | root = QTreeWidgetItem(self.tree) 28 | root.setText(0,'根节点') 29 | root.setIcon(0,QIcon('./images/root.png')) 30 | self.tree.setColumnWidth(0,160) 31 | 32 | # 添加子节点1 33 | child1 = QTreeWidgetItem(root) 34 | child1.setText(0,'子节点1') 35 | child1.setText(1,'子节点1的数据') 36 | child1.setIcon(0,QIcon('./images/bao3.png')) 37 | child1.setCheckState(0,Qt.Checked) 38 | 39 | # 添加子节点2 40 | child2 = QTreeWidgetItem(root) 41 | child2.setText(0,'子节点2') 42 | child2.setIcon(0,QIcon('./images/bao6.png')) 43 | 44 | # 为child2添加一个子节点 45 | child3 = QTreeWidgetItem(child2) 46 | child3.setText(0,'子节点2-1') 47 | child3.setText(1,'新的值') 48 | child3.setIcon(0,QIcon('./images/music.png')) 49 | 50 | 51 | self.tree.expandAll() 52 | 53 | self.setCentralWidget(self.tree) 54 | 55 | if __name__ == '__main__': 56 | app = QApplication(sys.argv) 57 | tree = BasicTreeWidget() 58 | tree.show() 59 | sys.exit(app.exec_()) 60 | -------------------------------------------------------------------------------- /src/multithread/ShowTime.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 动态显示当前时间 4 | 5 | QTimer 6 | QThread 7 | 8 | 多线程:用于同时完成多个任务 9 | 10 | 11 | 12 | 13 | ''' 14 | 15 | from PyQt5.QtWidgets import QWidget, QPushButton, QApplication, QListWidget, QGridLayout, QLabel 16 | from PyQt5.QtCore import QTimer, QDateTime 17 | import sys 18 | 19 | 20 | class ShowTime(QWidget): 21 | 22 | def __init__(self, parent=None): 23 | super(ShowTime, self).__init__(parent) 24 | self.setWindowTitle("动态显示当前时间") 25 | 26 | self.label = QLabel('显示当前时间') 27 | self.startBtn = QPushButton('开始') 28 | self.endBtn = QPushButton('结束') 29 | layout= QGridLayout() 30 | 31 | self.timer = QTimer() 32 | self.timer.timeout.connect(self.showTime) 33 | 34 | layout.addWidget(self.label,0,0,1,2) 35 | layout.addWidget(self.startBtn,1,0) 36 | layout.addWidget(self.endBtn,1,1) 37 | 38 | self.startBtn.clicked.connect(self.startTimer) 39 | self.endBtn.clicked.connect(self.endTimer) 40 | 41 | self.setLayout(layout) 42 | 43 | def showTime(self): 44 | time = QDateTime.currentDateTime() 45 | 46 | timeDisplay = time.toString("yyyy-MM-dd hh:mm:ss dddd") 47 | self.label.setText(timeDisplay) 48 | 49 | def startTimer(self): 50 | self.timer.start(1000) 51 | self.startBtn.setEnabled(False) 52 | self.endBtn.setEnabled(True) 53 | 54 | def endTimer(self): 55 | self.timer.stop() 56 | self.startBtn.setEnabled(True) 57 | self.endBtn.setEnabled(False) 58 | 59 | if __name__ == "__main__": 60 | app = QApplication(sys.argv) 61 | form = ShowTime() 62 | form.show() 63 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/dialogs/QFileDialogDemo.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 文件对话框:QFileDialog 4 | 5 | ''' 6 | 7 | import sys 8 | from PyQt5.QtCore import * 9 | from PyQt5.QtGui import * 10 | from PyQt5.QtWidgets import * 11 | class QFileDialogDemo(QWidget): 12 | def __init__(self): 13 | super(QFileDialogDemo,self).__init__() 14 | self.initUI() 15 | 16 | def initUI(self): 17 | layout = QVBoxLayout() 18 | self.button1 = QPushButton('加载图片') 19 | self.button1.clicked.connect(self.loadImage) 20 | layout.addWidget(self.button1) 21 | 22 | self.imageLabel = QLabel() 23 | layout.addWidget(self.imageLabel) 24 | 25 | self.button2 = QPushButton('加载文本文件') 26 | self.button2.clicked.connect(self.loadText) 27 | layout.addWidget(self.button2) 28 | 29 | self.contents = QTextEdit() 30 | layout.addWidget(self.contents) 31 | 32 | self.setLayout(layout) 33 | self.setWindowTitle('文件对话框演示 ') 34 | 35 | def loadImage(self): 36 | fname,_ = QFileDialog.getOpenFileName(self,'打开文件','.','图像文件(*.jpg *.png)') 37 | self.imageLabel.setPixmap(QPixmap(fname)) 38 | 39 | def loadText(self): 40 | dialog = QFileDialog() 41 | dialog.setFileMode(QFileDialog.AnyFile) 42 | dialog.setFilter(QDir.Files) 43 | 44 | if dialog.exec(): 45 | filenames = dialog.selectedFiles() 46 | f = open(filenames[0],encoding='utf-8',mode='r') 47 | with f: 48 | data = f.read() 49 | self.contents.setText(data) 50 | 51 | if __name__ == '__main__': 52 | app = QApplication(sys.argv) 53 | main = QFileDialogDemo() 54 | main.show() 55 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/SignalSlot/NewDateDialog.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import * 2 | from PyQt5.QtGui import * 3 | from PyQt5.QtWidgets import * 4 | 5 | from PyQt5.QtCore import * 6 | from PyQt5.QtGui import * 7 | from PyQt5.QtWidgets import * 8 | 9 | 10 | class NewDateDialog(QDialog): 11 | Signal_OneParameter = pyqtSignal(str) 12 | 13 | def __init__(self, parent=None): 14 | super(NewDateDialog, self).__init__(parent) 15 | self.setWindowTitle('子窗口:用来发射信号') 16 | 17 | # 在布局中添加部件 18 | layout = QVBoxLayout(self) 19 | 20 | self.label = QLabel(self) 21 | self.label.setText('前者发射内置信号\n后者发射自定义信号') 22 | 23 | self.datetime_inner = QDateTimeEdit(self) 24 | self.datetime_inner.setCalendarPopup(True) 25 | self.datetime_inner.setDateTime(QDateTime.currentDateTime()) 26 | 27 | self.datetime_emit = QDateTimeEdit(self) 28 | self.datetime_emit.setCalendarPopup(True) 29 | self.datetime_emit.setDateTime(QDateTime.currentDateTime()) 30 | 31 | layout.addWidget(self.label) 32 | layout.addWidget(self.datetime_inner) 33 | layout.addWidget(self.datetime_emit) 34 | 35 | # 使用两个button(ok和cancel)分别连接accept()和reject()槽函数 36 | buttons = QDialogButtonBox( 37 | QDialogButtonBox.Ok | QDialogButtonBox.Cancel, 38 | Qt.Horizontal, self) 39 | buttons.accepted.connect(self.accept) 40 | buttons.rejected.connect(self.reject) 41 | layout.addWidget(buttons) 42 | 43 | self.datetime_emit.dateTimeChanged.connect(self.emit_signal) 44 | 45 | def emit_signal(self): 46 | date_str = self.datetime_emit.dateTime().toString() 47 | self.Signal_OneParameter.emit(date_str) 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/windows/AbnormityWindow.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 实现不规则窗口(异形窗口) 4 | 5 | 通过mask实现异形窗口 6 | 7 | 需要一张透明的png图,透明部分被扣出,形成一个非矩形的区域 8 | 9 | 10 | 移动和关闭不规则窗口 11 | ''' 12 | 13 | import sys 14 | from PyQt5.QtWidgets import * 15 | from PyQt5.QtGui import * 16 | from PyQt5.QtCore import * 17 | 18 | class AbnormityWindow(QWidget): 19 | def __init__(self): 20 | super().__init__() 21 | self.setWindowTitle("异形窗口") 22 | self.pix = QBitmap('./images/mask.png') 23 | self.resize(self.pix.size()) 24 | self.setMask(self.pix) 25 | 26 | def mousePressEvent(self, event): 27 | if event.button() == Qt.LeftButton: 28 | self.m_drag = True 29 | 30 | self.m_DragPosition = event.globalPos() - self.pos() 31 | self.setCursor(QCursor(Qt.OpenHandCursor)) 32 | print(event.globalPos()) # 33 | print(event.pos()) 34 | print(self.pos()) 35 | if event.button() == Qt.RightButton: 36 | self.close() 37 | 38 | def mouseMoveEvent(self, QMouseEvent): 39 | if Qt.LeftButton and self.m_drag: 40 | # 当左键移动窗体修改偏移值 41 | # QPoint 42 | # 实时计算窗口左上角坐标 43 | self.move(QMouseEvent.globalPos() - self.m_DragPosition) 44 | 45 | 46 | def mouseReleaseEvent(self, QMouseEvent): 47 | self.m_drag = False 48 | self.setCursor(QCursor(Qt.ArrowCursor)) 49 | def paintEvent(self, event): 50 | painter = QPainter(self) 51 | painter.drawPixmap(0,0,self.pix.width(),self.pix.height(),QPixmap('./images/screen1.jpg')) 52 | if __name__ == "__main__": 53 | app = QApplication(sys.argv) 54 | form = AbnormityWindow() 55 | form.show() 56 | sys.exit(app.exec_()) 57 | -------------------------------------------------------------------------------- /src/drawing/DrawAll.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 绘制各种图形 4 | 5 | 弧 6 | 圆形 7 | 椭圆 8 | 矩形(正方形) 9 | 多边形 10 | 绘制图像 11 | 12 | ''' 13 | 14 | import sys,math 15 | from PyQt5.QtWidgets import * 16 | from PyQt5.QtGui import * 17 | from PyQt5.QtCore import * 18 | 19 | class DrawAll(QWidget): 20 | def __init__(self): 21 | super(DrawAll,self).__init__() 22 | self.resize(300,600) 23 | self.setWindowTitle('绘制各种图形') 24 | def paintEvent(self, event): 25 | qp = QPainter() 26 | qp.begin(self) 27 | 28 | qp.setPen(Qt.blue) 29 | 30 | # 绘制弧 31 | rect = QRect(0,10,100,100) 32 | # alen: 1个alen等于1/16度 45 * 16 33 | qp.drawArc(rect,0, 50 * 16) 34 | # 通过弧绘制圆 35 | qp.setPen(Qt.red) 36 | qp.drawArc(120,10,100,100,0, 360 * 16) 37 | 38 | # 绘制带弦的弧 39 | qp.drawChord(10,120,100,100,12,130*16) 40 | 41 | # 绘制扇形 42 | qp.drawPie(10,240,100,100,12,130*16) 43 | 44 | # 椭圆 45 | qp.drawEllipse(120,120,150,100) 46 | # 绘制5边形 47 | point1 = QPoint(140,380) 48 | point2 = QPoint(270,420) 49 | point3 = QPoint(290,512) 50 | point4 = QPoint(290,588) 51 | point5 = QPoint(200,533) 52 | 53 | polygon = QPolygon([point1,point2,point3,point4,point5]) 54 | qp.drawPolygon(polygon) 55 | 56 | # 绘制图像 57 | image = QImage('./images/book1.png') 58 | rect = QRect(10, 400, image.width()/3, image.height()/3) 59 | #image.save('./images/book1.png') 60 | qp.drawImage(rect,image) 61 | 62 | qp.end() 63 | 64 | 65 | if __name__ == '__main__': 66 | app = QApplication(sys.argv) 67 | main = DrawAll() 68 | main.show() 69 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/containers/TabWidget.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 选项卡控件:QTabWidget 4 | 5 | 6 | 7 | ''' 8 | 9 | import sys 10 | from PyQt5.QtCore import * 11 | from PyQt5.QtGui import * 12 | from PyQt5.QtWidgets import * 13 | 14 | 15 | class TabWidgetDemo(QTabWidget): 16 | def __init__(self, parent=None): 17 | super(TabWidgetDemo, self).__init__(parent) 18 | 19 | self.setWindowTitle("选项卡控件:QTabWidget") 20 | # 创建用于显示控件的窗口 21 | self.tab1 = QWidget() 22 | self.tab2 = QWidget() 23 | self.tab3 = QWidget() 24 | 25 | self.addTab(self.tab1,'选项卡1') 26 | self.addTab(self.tab2,'选项卡2') 27 | self.addTab(self.tab3,'选项卡3') 28 | 29 | self.tab1UI() 30 | self.tab2UI() 31 | self.tab3UI() 32 | 33 | def tab1UI(self): 34 | layout = QFormLayout() 35 | layout.addRow('姓名',QLineEdit()) 36 | layout.addRow('地址',QLineEdit()) 37 | self.setTabText(0,'联系方式') 38 | self.tab1.setLayout(layout) 39 | 40 | def tab2UI(self): 41 | layout = QFormLayout() 42 | sex = QHBoxLayout() 43 | sex.addWidget(QRadioButton('男')) 44 | sex.addWidget(QRadioButton('女')) 45 | layout.addRow(QLabel('性别'),sex) 46 | layout.addRow('生日',QLineEdit()) 47 | self.setTabText(1,'个人详细信息') 48 | self.tab2.setLayout(layout) 49 | 50 | def tab3UI(self): 51 | layout = QHBoxLayout() 52 | layout.addWidget(QLabel('科目')) 53 | layout.addWidget(QCheckBox('物理')) 54 | layout.addWidget(QCheckBox('高数')) 55 | self.setTabText(2,'教育程度') 56 | self.tab3.setLayout(layout) 57 | 58 | if __name__ == '__main__': 59 | app = QApplication(sys.argv) 60 | demo = TabWidgetDemo() 61 | demo.show() 62 | sys.exit(app.exec_()) 63 | -------------------------------------------------------------------------------- /src/controls/QLineEditEchoMode.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | QLineEdit控件与回显模式 4 | 5 | 基本功能:输入单行的文本 6 | 7 | EchoMode(回显模式) 8 | 9 | 4种回显模式 10 | 11 | 1. Normal 12 | 2. NoEcho 13 | 3. Password 14 | 4. PasswordEchoOnEdit 15 | 16 | 17 | Mac : Command Windows:Control 18 | ''' 19 | from PyQt5.QtWidgets import * 20 | import sys 21 | 22 | class QLineEditEchoMode(QWidget) : 23 | def __init__(self): 24 | super(QLineEditEchoMode,self).__init__() 25 | self.initUI() 26 | 27 | def initUI(self): 28 | self.setWindowTitle('文本输入框的回显模式') 29 | 30 | formLayout = QFormLayout() 31 | 32 | normalLineEdit = QLineEdit() 33 | noEchoLineEdit = QLineEdit() 34 | passwordLineEdit = QLineEdit() 35 | passwordEchoOnEditLineEdit = QLineEdit() 36 | 37 | formLayout.addRow("Normal",normalLineEdit) 38 | formLayout.addRow("NoEcho", noEchoLineEdit) 39 | formLayout.addRow("Password",passwordLineEdit) 40 | formLayout.addRow("PasswordEchoOnEdit",passwordEchoOnEditLineEdit) 41 | 42 | # placeholdertext 43 | 44 | normalLineEdit.setPlaceholderText("Normal") 45 | noEchoLineEdit.setPlaceholderText("NoEcho") 46 | passwordLineEdit.setPlaceholderText("Password") 47 | passwordEchoOnEditLineEdit.setPlaceholderText("PasswordEchoOnEdit") 48 | 49 | normalLineEdit.setEchoMode(QLineEdit.Normal) 50 | noEchoLineEdit.setEchoMode(QLineEdit.NoEcho) 51 | passwordLineEdit.setEchoMode(QLineEdit.Password) 52 | passwordEchoOnEditLineEdit.setEchoMode(QLineEdit.PasswordEchoOnEdit) 53 | 54 | self.setLayout(formLayout) 55 | 56 | if __name__ == '__main__': 57 | app = QApplication(sys.argv) 58 | main = QLineEditEchoMode() 59 | main.show() 60 | sys.exit(app.exec_()) 61 | -------------------------------------------------------------------------------- /src/ext/pyqtgraph_pyqt.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'pyqtgraph_pyqt.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.9.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore, QtGui, QtWidgets 10 | 11 | class Ui_MainWindow(object): 12 | def setupUi(self, MainWindow): 13 | MainWindow.setObjectName("MainWindow") 14 | MainWindow.resize(800, 600) 15 | self.centralwidget = QtWidgets.QWidget(MainWindow) 16 | self.centralwidget.setObjectName("centralwidget") 17 | self.pyqtgraph1 = GraphicsLayoutWidget(self.centralwidget) 18 | self.pyqtgraph1.setGeometry(QtCore.QRect(10, 10, 721, 251)) 19 | self.pyqtgraph1.setObjectName("pyqtgraph1") 20 | self.pyqtgraph2 = GraphicsLayoutWidget(self.centralwidget) 21 | self.pyqtgraph2.setGeometry(QtCore.QRect(10, 290, 501, 281)) 22 | self.pyqtgraph2.setObjectName("pyqtgraph2") 23 | MainWindow.setCentralWidget(self.centralwidget) 24 | self.menubar = QtWidgets.QMenuBar(MainWindow) 25 | self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22)) 26 | self.menubar.setObjectName("menubar") 27 | MainWindow.setMenuBar(self.menubar) 28 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 29 | self.statusbar.setObjectName("statusbar") 30 | MainWindow.setStatusBar(self.statusbar) 31 | 32 | self.retranslateUi(MainWindow) 33 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 34 | 35 | def retranslateUi(self, MainWindow): 36 | _translate = QtCore.QCoreApplication.translate 37 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 38 | 39 | from pyqtgraph import GraphicsLayoutWidget 40 | -------------------------------------------------------------------------------- /src/ext/DataGrid.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 使用可视化的方式对SQLite数据库进行增、删、改、查操作 4 | 5 | 6 | QTableView 7 | 8 | QSqlTableModel 9 | 10 | 11 | ''' 12 | import sys 13 | from PyQt5.QtCore import * 14 | from PyQt5.QtGui import * 15 | from PyQt5.QtWidgets import * 16 | from PyQt5.QtSql import * 17 | 18 | def initializeModel(model): 19 | model.setTable('people') 20 | model.setEditStrategy(QSqlTableModel.OnFieldChange) 21 | model.select() 22 | model.setHeaderData(0, Qt.Horizontal,'ID') 23 | model.setHeaderData(1, Qt.Horizontal, '姓名') 24 | model.setHeaderData(2, Qt.Horizontal, '地址') 25 | 26 | def createView(title,model): 27 | view = QTableView() 28 | view.setModel(model) 29 | view.setWindowTitle(title) 30 | return view 31 | def findrow(i): 32 | delrow = i.row() 33 | print('del row=%s' % str(delrow)) 34 | def addrow(): 35 | ret = model.insertRows(model.rowCount(),1) 36 | print('insertRow=%s' % str(ret)) 37 | if __name__ == '__main__': 38 | app = QApplication(sys.argv) 39 | db = QSqlDatabase.addDatabase('QSQLITE') 40 | db.setDatabaseName('./db/database.db') 41 | model = QSqlTableModel() 42 | delrow = -1 43 | initializeModel(model) 44 | view = createView("展示数据",model) 45 | view.clicked.connect(findrow) 46 | 47 | dlg = QDialog() 48 | layout = QVBoxLayout() 49 | layout.addWidget(view) 50 | addBtn = QPushButton('添加一行') 51 | addBtn.clicked.connect(addrow) 52 | 53 | delBtn = QPushButton('删除一行') 54 | delBtn.clicked.connect(lambda :model.removeRow(view.currentIndex().row())) 55 | layout.addWidget(view) 56 | layout.addWidget(addBtn) 57 | layout.addWidget(delBtn) 58 | dlg.setLayout(layout) 59 | dlg.setWindowTitle("Database Demo") 60 | dlg.resize(500,400) 61 | dlg.show() 62 | sys.exit(app.exec()) -------------------------------------------------------------------------------- /src/controls/QLineEditDemo.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | QLineEdit综合案例 4 | 5 | ''' 6 | 7 | from PyQt5.QtWidgets import * 8 | from PyQt5.QtGui import * 9 | from PyQt5.QtCore import Qt 10 | import sys 11 | 12 | class QLineEditDemo(QWidget): 13 | def __init__(self): 14 | super(QLineEditDemo,self).__init__() 15 | self.initUI() 16 | 17 | def initUI(self): 18 | edit1 = QLineEdit() 19 | # 使用int校验器 20 | edit1.setValidator(QIntValidator()) 21 | edit1.setMaxLength(4) # 不超过9999 22 | edit1.setAlignment(Qt.AlignRight) 23 | edit1.setFont(QFont('Arial',20)) 24 | 25 | edit2 = QLineEdit() 26 | edit2.setValidator(QDoubleValidator(0.99,99.99,2)) 27 | 28 | edit3 = QLineEdit() 29 | edit3.setInputMask('99_9999_999999;#') 30 | 31 | edit4 = QLineEdit() 32 | edit4.textChanged.connect(self.textChanged) 33 | 34 | edit5 = QLineEdit() 35 | edit5.setEchoMode(QLineEdit.Password) 36 | edit5.editingFinished.connect(self.enterPress) 37 | 38 | edit6 = QLineEdit('Hello PyQt5') 39 | edit6.setReadOnly(True) 40 | 41 | 42 | formLayout = QFormLayout() 43 | formLayout.addRow('整数校验',edit1) 44 | formLayout.addRow('浮点数校验',edit2) 45 | formLayout.addRow('Input Mask',edit3) 46 | formLayout.addRow('文本变化', edit4) 47 | formLayout.addRow('密码',edit5) 48 | formLayout.addRow('只读',edit6) 49 | self.setLayout(formLayout) 50 | self.setWindowTitle('QLineEdit综合案例') 51 | def textChanged(self,text): 52 | print('输入的内容:' + text) 53 | 54 | def enterPress(self): 55 | print('已输入值') 56 | if __name__ == '__main__': 57 | app = QApplication(sys.argv) 58 | main = QLineEditDemo() 59 | main.show() 60 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /.idea/pyqt5.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | -------------------------------------------------------------------------------- /src/controls/QTextEditDemo.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | QTextEdit控件 4 | 5 | ''' 6 | 7 | from PyQt5.QtWidgets import * 8 | import sys 9 | 10 | class QTextEditDemo(QWidget) : 11 | def __init__(self): 12 | super(QTextEditDemo,self).__init__() 13 | self.initUI() 14 | 15 | def initUI(self): 16 | self.setWindowTitle('QTextEdit控件演示') 17 | 18 | self.resize(300,320) 19 | 20 | self.textEdit = QTextEdit() 21 | self.buttonText = QPushButton('显示文本') 22 | self.buttonHTML = QPushButton('显示HTML') 23 | 24 | self.buttonToText = QPushButton('获取文本') 25 | self.buttonToHTML = QPushButton('获取HTML') 26 | 27 | 28 | layout = QVBoxLayout() 29 | layout.addWidget(self.textEdit) 30 | layout.addWidget(self.buttonText) 31 | layout.addWidget(self.buttonToText) 32 | layout.addWidget(self.buttonHTML) 33 | layout.addWidget(self.buttonToHTML) 34 | 35 | self.setLayout(layout) 36 | 37 | self.buttonText.clicked.connect(self.onClick_ButtonText) 38 | self.buttonHTML.clicked.connect(self.onClick_ButtonHTML) 39 | 40 | self.buttonToText.clicked.connect(self.onClick_ButtonToText) 41 | self.buttonToHTML.clicked.connect(self.onClick_ButtonToHTML) 42 | 43 | def onClick_ButtonText(self): 44 | self.textEdit.setPlainText('Hello World,世界你好吗?') 45 | 46 | def onClick_ButtonToText(self): 47 | print(self.textEdit.toPlainText()) 48 | 49 | def onClick_ButtonHTML(self): 50 | self.textEdit.setHtml('Hello World') 51 | def onClick_ButtonToHTML(self): 52 | print(self.textEdit.toHtml()) 53 | 54 | if __name__ == '__main__': 55 | app = QApplication(sys.argv) 56 | main = QTextEditDemo() 57 | main.show() 58 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/DarkStyleSheet.py: -------------------------------------------------------------------------------- 1 | 2 | ''' 3 | QDarkStyleSheet样式 4 | 5 | conda install qdarkstyle 6 | ''' 7 | import logging 8 | import sys 9 | from PyQt5 import QtWidgets, QtCore 10 | # make the example runnable without the need to install 11 | from os.path import abspath, dirname 12 | sys.path.insert(0, abspath(dirname(abspath(__file__)) + '/..')) 13 | 14 | import qdarkstyle 15 | import ui.example_pyqt5_ui as example_ui 16 | 17 | 18 | def main(): 19 | """ 20 | Application entry point 21 | """ 22 | logging.basicConfig(level=logging.DEBUG) 23 | # create the application and the main window 24 | app = QtWidgets.QApplication(sys.argv) 25 | window = QtWidgets.QMainWindow() 26 | 27 | # setup ui 28 | ui = example_ui.Ui_MainWindow() 29 | ui.setupUi(window) 30 | ui.bt_delay_popup.addActions([ 31 | ui.actionAction, 32 | ui.actionAction_C 33 | ]) 34 | ui.bt_instant_popup.addActions([ 35 | ui.actionAction, 36 | ui.actionAction_C 37 | ]) 38 | ui.bt_menu_button_popup.addActions([ 39 | ui.actionAction, 40 | ui.actionAction_C 41 | ]) 42 | item = QtWidgets.QTableWidgetItem("Test") 43 | item.setCheckState(QtCore.Qt.Checked) 44 | ui.tableWidget.setItem(0, 0, item) 45 | window.setWindowTitle("QDarkStyle example") 46 | 47 | # tabify dock widgets to show bug #6 48 | window.tabifyDockWidget(ui.dockWidget1, ui.dockWidget2) 49 | 50 | # setup stylesheet 51 | print(qdarkstyle.load_stylesheet_pyqt5()) 52 | app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) 53 | 54 | # auto quit after 2s when testing on travis-ci 55 | if "--travis" in sys.argv: 56 | QtCore.QTimer.singleShot(2000, app.exit) 57 | 58 | # run 59 | window.show() 60 | app.exec_() 61 | 62 | 63 | if __name__ == "__main__": 64 | main() 65 | -------------------------------------------------------------------------------- /src/controls/QLineEditMask.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 用掩码限制QLineEdit控件的输入 4 | 5 | A ASCII字母字符是必须输入的(A-Z、a-z) 6 | a ASCII字母字符是允许输入的,但不是必需的(A-Z、a-z) 7 | N ASCII字母字符是必须输入的(A-Z、a-z、0-9) 8 | n ASII字母字符是允许输入的,但不是必需的(A-Z、a-z、0-9) 9 | X 任何字符都是必须输入的 10 | x 任何字符都是允许输入的,但不是必需的 11 | 9 ASCII数字字符是必须输入的(0-9) 12 | 0 ASCII数字字符是允许输入的,但不是必需的(0-9) 13 | D ASCII数字字符是必须输入的(1-9) 14 | d ASCII数字字符是允许输入的,但不是必需的(1-9) 15 | # ASCI数字字符或加减符号是允许输入的,但不是必需的 16 | H 十六进制格式字符是必须输入的(A-F、a-f、0-9) 17 | h 十六进制格式字符是允许输入的,但不是必需的(A-F、a-f、0-9) 18 | B 二进制格式字符是必须输入的(0,1) 19 | b 二进制格式字符是允许输入的,但不是必需的(0,1) 20 | > 所有的字母字符都大写 21 | < 所有的字母字符都小写 22 | ! 关闭大小写转换 23 | \ 使用"\"转义上面列出的字符 24 | ''' 25 | 26 | from PyQt5.QtWidgets import * 27 | import sys 28 | 29 | class QLineEditMask(QWidget) : 30 | def __init__(self): 31 | super(QLineEditMask,self).__init__() 32 | self.initUI() 33 | 34 | def initUI(self): 35 | self.setWindowTitle('用掩码限制QLineEdit控件的输入') 36 | formLayout = QFormLayout() 37 | 38 | ipLineEdit = QLineEdit() 39 | macLineEdit = QLineEdit() 40 | dateLineEdit = QLineEdit() 41 | licenseLineEdit = QLineEdit() 42 | # 192.168.21.45 43 | ipLineEdit.setInputMask('000.000.000.000;_') 44 | macLineEdit.setInputMask('HH:HH:HH:HH:HH:HH;_') 45 | dateLineEdit.setInputMask('0000-00-00') 46 | licenseLineEdit.setInputMask('>AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;#') 47 | 48 | formLayout.addRow('数字掩码',ipLineEdit) 49 | formLayout.addRow('Mac掩码', macLineEdit) 50 | formLayout.addRow('日期掩码',dateLineEdit) 51 | formLayout.addRow('许可证掩码',licenseLineEdit) 52 | 53 | self.setLayout(formLayout) 54 | 55 | if __name__ == '__main__': 56 | app = QApplication(sys.argv) 57 | main = QLineEditMask() 58 | main.show() 59 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/SignalSlot/MultiWindow2.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 多窗口交互(2):使用信号与槽 4 | 5 | 如果一个窗口A与另一个窗口B交互,那么A尽量不要直接访问B窗口中的控件, 6 | 应该访问B窗口中的信号,并指定与信号绑定的槽函数 7 | 8 | 例:如果A直接访问B窗口的控件,一旦B窗口控件发生改变,那么A和B的代码都需要变化 9 | 10 | 如果A访问的是B中的信号,那么B中的控件发生了改变,只需要修改B中的代码即可 11 | 12 | 13 | 14 | ''' 15 | 16 | import sys 17 | from PyQt5.QtCore import * 18 | from PyQt5.QtGui import * 19 | from PyQt5.QtWidgets import * 20 | from NewDateDialog import NewDateDialog 21 | 22 | class MultiWindow2(QWidget): 23 | def __init__(self, parent=None): 24 | super(MultiWindow2, self).__init__(parent) 25 | self.resize(400, 90) 26 | self.setWindowTitle('多窗口交互(2):使用信号与槽') 27 | 28 | self.open_btn = QPushButton('获取时间') 29 | self.lineEdit_inner = QLineEdit(self) 30 | self.lineEdit_emit = QLineEdit(self) 31 | self.open_btn.clicked.connect(self.openDialog) 32 | 33 | self.lineEdit_inner.setText('接收子窗口内置信号的时间') 34 | self.lineEdit_emit.setText('接收子窗口自定义信号的时间') 35 | 36 | grid = QGridLayout() 37 | grid.addWidget(self.lineEdit_inner) 38 | grid.addWidget(self.lineEdit_emit) 39 | 40 | grid.addWidget(self.open_btn) 41 | self.setLayout(grid) 42 | 43 | def openDialog(self): 44 | dialog = NewDateDialog(self) 45 | # 连接子窗口的内置信号与主窗口的槽函数 46 | dialog.datetime_inner.dateTimeChanged.connect(self.deal_inner_slot) 47 | # 连接子窗口的自定义信号与主窗口的槽函数 48 | dialog.Signal_OneParameter.connect(self.deal_emit_slot) 49 | dialog.show() 50 | 51 | def deal_inner_slot(self, date): 52 | self.lineEdit_inner.setText(date.toString()) 53 | 54 | 55 | def deal_emit_slot(self, dateStr): 56 | self.lineEdit_emit.setText(dateStr) 57 | 58 | if __name__ == "__main__": 59 | app = QApplication(sys.argv) 60 | form = MultiWindow2() 61 | form.show() 62 | sys.exit(app.exec_()) 63 | -------------------------------------------------------------------------------- /src/dialogs/QInputDialogDemo.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 输入对话框:QInputDialog 4 | 5 | QInputDialog.getItem 6 | QInputDialog.getText 7 | QInputDialog.getInt 8 | 9 | ''' 10 | 11 | import sys 12 | from PyQt5.QtCore import * 13 | from PyQt5.QtGui import * 14 | from PyQt5.QtWidgets import * 15 | class QInputDialogDemo(QWidget): 16 | def __init__(self): 17 | super(QInputDialogDemo,self).__init__() 18 | self.initUI() 19 | 20 | def initUI(self): 21 | self.setWindowTitle('输入对话框') 22 | layout = QFormLayout() 23 | 24 | self.button1 = QPushButton('获取列表中的选项') 25 | self.button1.clicked.connect(self.getItem) 26 | self.lineEdit1 = QLineEdit() 27 | layout.addRow(self.button1, self.lineEdit1) 28 | 29 | self.button2 = QPushButton('获取字符串') 30 | self.button2.clicked.connect(self.getText) 31 | self.lineEdit2 = QLineEdit() 32 | layout.addRow(self.button2, self.lineEdit2) 33 | 34 | self.button3 = QPushButton('获取整数') 35 | self.button3.clicked.connect(self.getInt) 36 | self.lineEdit3 = QLineEdit() 37 | layout.addRow(self.button3, self.lineEdit3) 38 | 39 | self.setLayout(layout) 40 | 41 | def getItem(self): 42 | items = ('C','C++','Ruby','Python','Java') 43 | item, ok =QInputDialog.getItem(self,'请选择编程语言','语言列表',items) 44 | if ok and item: 45 | self.lineEdit1.setText(item) 46 | def getText(self): 47 | text, ok =QInputDialog.getText(self,'文本输入框','输入姓名') 48 | if ok and text: 49 | self.lineEdit2.setText(text) 50 | def getInt(self): 51 | num, ok =QInputDialog.getInt(self,'整数输入框','输入数字') 52 | if ok and num: 53 | self.lineEdit3.setText(str(num)) 54 | 55 | if __name__ == '__main__': 56 | app = QApplication(sys.argv) 57 | main = QInputDialogDemo() 58 | main.show() 59 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/table_tree/TableWidget.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 扩展的表格控件(QTableWidget) 4 | 5 | QTableView 6 | 7 | 每一个Cell(单元格)是一个QTableWidgetItem 8 | 9 | ''' 10 | 11 | import sys 12 | from PyQt5.QtWidgets import (QWidget, QTableWidget, QHBoxLayout, QApplication, QTableWidgetItem, QAbstractItemView) 13 | 14 | 15 | class TableWidgetDemo(QWidget): 16 | def __init__(self): 17 | super(TableWidgetDemo,self).__init__() 18 | self.initUI() 19 | 20 | def initUI(self): 21 | self.setWindowTitle("QTableWidget演示") 22 | self.resize(430, 230); 23 | layout = QHBoxLayout() 24 | tablewidget = QTableWidget() 25 | tablewidget.setRowCount(4) 26 | tablewidget.setColumnCount(3) 27 | 28 | layout.addWidget(tablewidget) 29 | 30 | tablewidget.setHorizontalHeaderLabels(['姓名','年龄','籍贯']) 31 | nameItem = QTableWidgetItem("小明") 32 | tablewidget.setItem(0,0,nameItem) 33 | 34 | ageItem = QTableWidgetItem("24") 35 | tablewidget.setItem(0,1,ageItem) 36 | 37 | jgItem = QTableWidgetItem("北京") 38 | tablewidget.setItem(0,2,jgItem) 39 | 40 | # 禁止编辑 41 | tablewidget.setEditTriggers(QAbstractItemView.NoEditTriggers) 42 | 43 | # 整行选择 44 | tablewidget.setSelectionBehavior(QAbstractItemView.SelectRows) 45 | # 调整列和行 46 | tablewidget.resizeColumnsToContents() 47 | tablewidget.resizeRowsToContents() 48 | 49 | tablewidget.horizontalHeader().setVisible(False) 50 | # tablewidget.verticalHeader().setVisible(False) 51 | 52 | tablewidget.setVerticalHeaderLabels(["a","b"]) 53 | 54 | # 隐藏表格线 55 | tablewidget.setShowGrid(False) 56 | 57 | self.setLayout(layout) 58 | 59 | 60 | if __name__ == '__main__': 61 | app = QApplication(sys.argv) 62 | example = TableWidgetDemo() 63 | example.show() 64 | sys.exit(app.exec_()) 65 | -------------------------------------------------------------------------------- /src/SignalSlot/MultiSignal.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 为类添加多个信号 3 | 4 | ''' 5 | 6 | from PyQt5.QtCore import * 7 | 8 | class MultiSignal(QObject): 9 | 10 | signal1 = pyqtSignal() 11 | 12 | signal2 = pyqtSignal(int) 13 | 14 | signal3 = pyqtSignal(int, str) 15 | 16 | signal4 = pyqtSignal(list) 17 | 18 | signal5 = pyqtSignal(dict) 19 | 20 | # 声明一个重载版本的信号,也就是槽函数的参数可以是int和str类型,也可以只有一个str类型的参数 21 | signal6 = pyqtSignal([int,str],[str]) 22 | 23 | def __init__(self): 24 | super(MultiSignal,self).__init__() 25 | self.signal1.connect(self.signalCall1) 26 | self.signal2.connect(self.signalCall2) 27 | self.signal3.connect(self.signalCall3) 28 | self.signal4.connect(self.signalCall4) 29 | self.signal5.connect(self.signalCall5) 30 | self.signal6[str].connect(self.signalCall6Overload) 31 | self.signal6[int,str].connect(self.signalCall6) 32 | 33 | self.signal1.emit() 34 | self.signal2.emit(10) 35 | self.signal3.emit(1,"hello world") 36 | self.signal4.emit([1,2,3,4,5,6]) 37 | self.signal5.emit({"name":"Bill","age":30}) 38 | self.signal6[str].emit("test") 39 | self.signal6[int,str].emit(100,"mytest") 40 | def signalCall1(self): 41 | print("signal1 emit") 42 | 43 | def signalCall2(self,val): 44 | print("signal2 emit,value:", val) 45 | 46 | def signalCall3(self,val,text): 47 | print("signal3 emit,value:", val,text) 48 | 49 | def signalCall4(self,val): 50 | print("signal4 emit,value:", val) 51 | 52 | def signalCall5(self,val): 53 | print("signal5 emit,value:", val) 54 | 55 | def signalCall6(self,val,text): 56 | print("signal6 emit,value:", val,text) 57 | 58 | def signalCall6Overload(self,val): 59 | print("signal6 overload emit,value:", val) 60 | 61 | if __name__ == '__main__': 62 | multiSignal = MultiSignal() -------------------------------------------------------------------------------- /src/multithread/Counter.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 使用线程类(QThread)编写计数器 4 | 5 | 6 | QThread 7 | 8 | def run(self): 9 | while True: 10 | self.sleep(1) 11 | if sec == 5: 12 | break; 13 | 14 | QLCDNumber 15 | 16 | 17 | 18 | WorkThread(QThread) 19 | 用到自定义信号 20 | 21 | ''' 22 | 23 | import sys 24 | from PyQt5.QtCore import * 25 | from PyQt5.QtGui import * 26 | from PyQt5.QtWidgets import * 27 | 28 | sec = 0 29 | 30 | class WorkThread(QThread): 31 | timer = pyqtSignal() # 每隔1秒发送一次信号 32 | end = pyqtSignal() # 计数完成后发送一次信号 33 | def run(self): 34 | while True: 35 | self.sleep(1) # 休眠1秒 36 | if sec == 5: 37 | self.end.emit() # 发送end信号 38 | break 39 | self.timer.emit() # 发送timer信号 40 | 41 | class Counter(QWidget): 42 | 43 | def __init__(self, parent=None): 44 | super(Counter, self).__init__(parent) 45 | 46 | self.setWindowTitle("使用线程类(QThread)编写计数器") 47 | self.resize(300, 120) 48 | 49 | layout = QVBoxLayout() 50 | self.lcdNumber = QLCDNumber() 51 | layout.addWidget(self.lcdNumber) 52 | 53 | button = QPushButton('开始计数') 54 | layout.addWidget(button) 55 | 56 | self.workThread = WorkThread() 57 | 58 | self.workThread.timer.connect(self.countTime) 59 | self.workThread.end.connect(self.end) 60 | button.clicked.connect(self.work) 61 | 62 | self.setLayout(layout) 63 | 64 | def countTime(self): 65 | global sec 66 | sec += 1 67 | self.lcdNumber.display(sec) 68 | 69 | def end(self): 70 | QMessageBox.information(self,'消息','计数结束',QMessageBox.Ok) 71 | 72 | def work(self): 73 | self.workThread.start() 74 | 75 | 76 | 77 | 78 | if __name__ == "__main__": 79 | app = QApplication(sys.argv) 80 | form = Counter() 81 | form.show() 82 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/windows/QDarkStyleSheet-master/qdarkstyle/style.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | rc/up_arrow_disabled.png 4 | rc/Hmovetoolbar.png 5 | rc/stylesheet-branch-end.png 6 | rc/branch_closed-on.png 7 | rc/stylesheet-vline.png 8 | rc/branch_closed.png 9 | rc/branch_open-on.png 10 | rc/transparent.png 11 | rc/right_arrow_disabled.png 12 | rc/sizegrip.png 13 | rc/close.png 14 | rc/close-hover.png 15 | rc/close-pressed.png 16 | rc/down_arrow.png 17 | rc/Vmovetoolbar.png 18 | rc/left_arrow.png 19 | rc/stylesheet-branch-more.png 20 | rc/up_arrow.png 21 | rc/right_arrow.png 22 | rc/left_arrow_disabled.png 23 | rc/Hsepartoolbar.png 24 | rc/branch_open.png 25 | rc/Vsepartoolbar.png 26 | rc/down_arrow_disabled.png 27 | rc/undock.png 28 | rc/checkbox_checked_disabled.png 29 | rc/checkbox_checked_focus.png 30 | rc/checkbox_checked.png 31 | rc/checkbox_indeterminate.png 32 | rc/checkbox_indeterminate_focus.png 33 | rc/checkbox_unchecked_disabled.png 34 | rc/checkbox_unchecked_focus.png 35 | rc/checkbox_unchecked.png 36 | rc/radio_checked_disabled.png 37 | rc/radio_checked_focus.png 38 | rc/radio_checked.png 39 | rc/radio_unchecked_disabled.png 40 | rc/radio_unchecked_focus.png 41 | rc/radio_unchecked.png 42 | 43 | 44 | style.qss 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/controls/QLineEditValidator.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | 现在QLineEdit控件的输入(校验器) 4 | 5 | 如限制只能输入整数、浮点数或满足一定条件的字符串 6 | 7 | 8 | ''' 9 | 10 | from PyQt5.QtWidgets import * 11 | from PyQt5.QtGui import QIntValidator,QDoubleValidator, QRegExpValidator 12 | from PyQt5.QtCore import QRegExp 13 | import sys 14 | 15 | class QLineEditValidator(QWidget): 16 | def __init__(self): 17 | super(QLineEditValidator,self).__init__() 18 | self.initUI() 19 | 20 | def initUI(self): 21 | self.setWindowTitle('校验器') 22 | 23 | # 创建表单布局 24 | formLayout = QFormLayout() 25 | 26 | intLineEdit = QLineEdit() 27 | doubleLineEdit = QLineEdit() 28 | validatorLineEdit = QLineEdit() 29 | 30 | formLayout.addRow('整数类型', intLineEdit) 31 | formLayout.addRow('浮点类型', doubleLineEdit) 32 | formLayout.addRow('数字和字母',validatorLineEdit) 33 | 34 | intLineEdit.setPlaceholderText('整型') 35 | doubleLineEdit.setPlaceholderText('浮点型') 36 | validatorLineEdit.setPlaceholderText('字母和数字') 37 | 38 | # 整数校验器 [1,99] 39 | intValidator = QIntValidator(self) 40 | intValidator.setRange(1,99) 41 | 42 | # 浮点校验器 [-360,360],精度:小数点后2位 43 | doubleValidator = QDoubleValidator(self) 44 | doubleValidator.setRange(-360,360) 45 | doubleValidator.setNotation(QDoubleValidator.StandardNotation) 46 | # 设置精度,小数点2位 47 | doubleValidator.setDecimals(2) 48 | 49 | # 字符和数字 50 | reg = QRegExp('[a-zA-z0-9]+$') 51 | validator = QRegExpValidator(self) 52 | validator.setRegExp(reg) 53 | 54 | # 设置校验器 55 | 56 | intLineEdit.setValidator(intValidator) 57 | doubleLineEdit.setValidator(doubleValidator) 58 | validatorLineEdit.setValidator(validator) 59 | 60 | self.setLayout(formLayout) 61 | if __name__ == '__main__': 62 | app = QApplication(sys.argv) 63 | main = QLineEditValidator() 64 | main.show() 65 | sys.exit(app.exec_()) --------------------------------------------------------------------------------