Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0c16217

Browse files
committed
Update
1 parent 9a9d455 commit 0c16217

File tree

6 files changed

+77
-19
lines changed

6 files changed

+77
-19
lines changed

‎PyQt5/QtWidgets/Image drag and drop.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ def initUI(self):
1414
# QLabel{
1515
# border: 2px dashed gray;
1616
# }""")
17+
self.image.setScaledContents(True)
1718
self.image.setAlignment(Qt.AlignCenter)
1819
self.setCentralWidget(self.image)
1920
self.image.setAcceptDrops(True)
2021
self.setAcceptDrops(True)
2122
self.show()
22-
def paintEvent(self, pain_event):
23+
def paintEvent(self, paint_event):
2324
painter = QPainter()
2425
painter.begin(self)
26+
painter.setRenderHint(QPainter.HighQualityAntialiasing)
2527
painter.setPen(QPen(Qt.gray, 4, Qt.DashLine))
2628
painter.drawRect(10, 10, self.width() - 20, self.height() - 20)
2729
painter.end()
28-
super().paintEvent(pain_event)
30+
super().paintEvent(paint_event)
2931
def dragEnterEvent(self, event):
3032
if event.mimeData().hasImage:
3133
event.accept()

‎PyQt5/QtWidgets/QTextBrowser/navigation example/main.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def init_ui(self):
1414
style = self.style()
1515
self.backward_action = QAction("")
1616
self.backward_action.setDisabled(True)
17-
self.backward_action.setIcon(QIcon(style.standardIcon(QStyle.SP_ArrowBack).pixmap(24, 24)))
17+
self.backward_action.setIcon(style.standardIcon(QStyle.SP_ArrowBack))
1818
self.backward_action.triggered.connect(self.text_browser.backward)
1919
self.forward_action = QAction("")
2020
self.forward_action.setDisabled(True)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import sys
2+
3+
from PySide2.QtCore import QDir, QCoreApplication
4+
from PySide2.QtWidgets import QApplication, QWidget
5+
from PySide2.QtWinExtras import QWinJumpList, QWinJumpListItem, QWinJumpListCategory
6+
7+
8+
class Form(QWidget):
9+
def __init__(self):
10+
super().__init__()
11+
self.initUI()
12+
13+
def initUI(self):
14+
self.resize(500, 300)
15+
self.setWindowTitle("Windows Jump Lists")
16+
jumplist = QWinJumpList()
17+
tasks = jumplist.tasks()
18+
newProject = QWinJumpListItem(QWinJumpListItem.Link)
19+
newProject.setTitle("Create new project")
20+
newProject.setFilePath(QDir.toNativeSeparators(QCoreApplication.applicationFilePath()))
21+
newProject.setArguments("--new-project")
22+
tasks.addItem(newProject)
23+
# tasks.addLink("Launch SDK Manager", QDir.toNativeSeparators(QCoreApplication.applicationDirPath()) + "\\sdk-manager.exe")
24+
tasks.setVisible(True)
25+
self.show()
26+
27+
28+
app = QApplication(sys.argv)
29+
form = Form()
30+
sys.exit(app.exec_())
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
import sys
2+
23
from PySide2.QtWidgets import QApplication, QWidget
4+
from PySide2.QtGui import QIcon
35
from PySide2.QtWinExtras import QWinTaskbarButton
6+
7+
48
class Form(QWidget):
59
def __init__(self):
610
super().__init__()
711
self.initUI()
12+
813
def initUI(self):
914
self.resize(500, 300)
1015
self.setWindowTitle("Windows Taskbar ProgressBar")
1116
self.show()
1217
taskbar_button = QWinTaskbarButton(self)
1318
taskbar_button.setWindow(self.windowHandle())
1419
taskbar_progress = taskbar_button.progress()
15-
taskbar_progress.setVisible(True)
1620
taskbar_progress.setValue(60)
17-
# taskbar_progress.pause()
18-
# taskbar_progress.stop()
21+
taskbar_button.setOverlayIcon(QIcon("badge-1.ico"))
1922
taskbar_progress.show()
23+
24+
2025
app = QApplication(sys.argv)
2126
form = Form()
2227
sys.exit(app.exec_())
@@ -27,4 +32,4 @@ def initUI(self):
2732
#
2833
# QWinTaskbarProgress *progress = button->progress();
2934
# progress->setVisible(true);
30-
# progress->setValue(50);
35+
# progress->setValue(50);
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,46 @@
11
import sys
2+
23
from PySide2.QtCore import QBasicTimer
3-
from PySide2.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout
4+
from PySide2.QtWidgets import QApplication, QWidget, QPushButton, QCheckBox, QHBoxLayout
5+
from PySide2.QtGui import QIcon
46
from PySide2.QtWinExtras import QWinTaskbarButton
7+
8+
59
class Form(QWidget):
610
def __init__(self):
711
super().__init__()
812
self.initUI()
13+
914
def initUI(self):
1015
self.resize(500, 300)
1116
self.setWindowTitle("Windows Taskbar ProgressBar")
1217
self.start_stop_button = QPushButton("Start")
1318
self.start_stop_button.resize(self.start_stop_button.sizeHint())
1419
self.start_stop_button.clicked.connect(self.start_stop)
15-
self.pause_button = QPushButton("Pause")
16-
self.pause_button.resize(self.pause_button.sizeHint())
17-
self.pause_button.clicked.connect(self.pause)
18-
self.stop_button = QPushButton("Stop")
19-
self.stop_button.resize(self.stop_button.sizeHint())
20-
self.stop_button.clicked.connect(self.stop)
20+
self.pause_checkbox = QCheckBox("Pause")
21+
self.pause_checkbox.resize(self.pause_checkbox.sizeHint())
22+
self.pause_checkbox.clicked.connect(self.pause)
23+
self.stop_checkbox = QCheckBox("Stop")
24+
self.stop_checkbox.resize(self.stop_checkbox.sizeHint())
25+
self.stop_checkbox.clicked.connect(self.stop)
26+
self.overlay_checkbox = QCheckBox("Overlay icon")
27+
self.overlay_checkbox.resize(self.overlay_checkbox.sizeHint())
28+
self.overlay_checkbox.clicked.connect(self.toggle_overlay_icon)
2129
self.reset_button = QPushButton("Reset")
2230
self.reset_button.resize(self.reset_button.sizeHint())
2331
self.reset_button.clicked.connect(self.reset)
2432
self.hbox = QHBoxLayout()
2533
self.hbox.addWidget(self.start_stop_button)
26-
self.hbox.addWidget(self.pause_button)
27-
self.hbox.addWidget(self.stop_button)
34+
self.hbox.addWidget(self.pause_checkbox)
35+
self.hbox.addWidget(self.stop_checkbox)
36+
self.hbox.addWidget(self.overlay_checkbox)
2837
self.hbox.addWidget(self.reset_button)
2938
self.timer = QBasicTimer()
3039
self.step = 0
3140
self.setLayout(self.hbox)
3241
self.show()
3342
self.taskbar_init()
43+
3444
def taskbar_init(self):
3545
self.taskbar_button = QWinTaskbarButton(self)
3646
self.taskbar_button.setWindow(self.windowHandle())
@@ -40,13 +50,15 @@ def taskbar_init(self):
4050
self.taskbar_progress.setValue(0)
4151
self.taskbar_progress.setVisible(True)
4252
self.taskbar_progress.show()
53+
4354
def timerEvent(self, timer_event):
4455
if self.step <= 100:
4556
self.taskbar_progress.setValue(self.step)
4657
self.step += 1
4758
else:
4859
self.timer.stop()
4960
return super().timerEvent(timer_event)
61+
5062
def start_stop(self):
5163
if self.timer.isActive():
5264
self.timer.stop()
@@ -56,21 +68,30 @@ def start_stop(self):
5668
self.timer.start(100, self)
5769
self.start_stop_button.setText("Stop")
5870
self.start_stop_button.resize(self.start_stop_button.sizeHint())
71+
5972
def pause(self):
6073
if not self.taskbar_progress.isPaused():
6174
self.taskbar_progress.pause()
6275
elif self.taskbar_progress.isPaused():
6376
self.taskbar_progress.resume()
77+
6478
def stop(self):
6579
if not self.taskbar_progress.isStopped():
66-
self.timer.stop()
6780
self.taskbar_progress.stop()
6881
elif self.taskbar_progress.isStopped():
6982
self.taskbar_progress.resume()
83+
84+
def toggle_overlay_icon(self):
85+
if self.overlay_checkbox.isChecked():
86+
self.taskbar_button.setOverlayIcon(QIcon("badge-1.ico"))
87+
elif not self.overlay_checkbox.isChecked():
88+
self.taskbar_button.clearOverlayIcon()
89+
7090
def reset(self):
71-
self.timer.stop()
7291
self.step = 0
7392
self.taskbar_progress.reset()
93+
94+
7495
app = QApplication(sys.argv)
7596
form = Form()
76-
sys.exit(app.exec_())
97+
sys.exit(app.exec_())
14.7 KB
Binary file not shown.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /