Update links to https://www.learnpyqt.com
This commit is contained in:
@@ -44,12 +44,11 @@ The application window should appear.
|
||||
## Want to build your own apps?
|
||||
|
||||
> If you think these apps are neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
PyQt in general, take a look at [my free online tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
|
||||
You can also find more PyQt articles, tutorials and projects
|
||||
[on my website](http://martinfitzpatrick.name/tag/pyqt).
|
||||
You can also find write-ups about these apps
|
||||
[here](http://www.learnpyqt.com/apps).
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -6,10 +6,9 @@ browsing experience with the usual controls, as well as saving and loading HTML.
|
||||
|
||||

|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
|
||||
## Other licenses
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ class MainWindow(QMainWindow):
|
||||
"All files (*.*)")
|
||||
|
||||
if filename:
|
||||
html = self.browser.page().mainFrame().toHtml()
|
||||
html = self.browser.page().toHtml()
|
||||
with open(filename, 'w') as f:
|
||||
f.write(html)
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
|
||||
@@ -7,10 +7,9 @@ coincidental.
|
||||
|
||||

|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
|
||||
## Code notes
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ class MainWindow(QMainWindow):
|
||||
"All files (*.*)")
|
||||
|
||||
if filename:
|
||||
html = self.tabs.currentWidget().page().mainFrame().toHtml()
|
||||
html = self.tabs.currentWidget().page().toHtml()
|
||||
with open(filename, 'w') as f:
|
||||
f.write(html.encode('utf8'))
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
|
||||
@@ -91,7 +91,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
if self.current_op:
|
||||
self.last_operation = self.stack[-1], self.current_op
|
||||
|
||||
try:
|
||||
self.stack = [self.current_op(*self.stack)]
|
||||
except Exception:
|
||||
self.lcdNumber.display('Err')
|
||||
self.stack = [0]
|
||||
else:
|
||||
self.current_op = None
|
||||
self.state = READY
|
||||
self.display()
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
|
||||
@@ -7,10 +7,9 @@ them.
|
||||
|
||||

|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
|
||||
## Other licenses
|
||||
|
||||
|
||||
@@ -73,9 +73,6 @@ class MainWindow(QMainWindow):
|
||||
self.save_seq = 0
|
||||
|
||||
def take_photo(self):
|
||||
self.viewfinder.setContrast(100)
|
||||
#self.viewfinder.setBrightness(0)
|
||||
|
||||
timestamp = time.strftime("%d-%b-%Y-%H_%M_%S")
|
||||
self.capture.capture(os.path.join(self.save_path, "%s-%04d-%s.jpg" % (
|
||||
self.current_camera_name,
|
||||
|
||||
@@ -10,10 +10,9 @@ hand panel and updated to follow the position of the mouse.
|
||||
|
||||

|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
|
||||
## Code notes
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
requests>=2.0.0
|
||||
requests_cache>=0.4.13
|
||||
pyqtgraph>=0.10
|
||||
|
||||
@@ -15,7 +15,6 @@ which floats on top.
|
||||
|
||||

|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
@@ -118,15 +118,16 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
self.model.layoutChanged.emit()
|
||||
|
||||
def update_duration(self, mc):
|
||||
self.timeSlider.setMaximum(self.player.duration())
|
||||
duration = self.player.duration()
|
||||
def update_duration(self, duration):
|
||||
print("!", duration)
|
||||
print("?", self.player.duration())
|
||||
|
||||
self.timeSlider.setMaximum(duration)
|
||||
|
||||
if duration >= 0:
|
||||
self.totalTimeLabel.setText(hhmmss(duration))
|
||||
|
||||
def update_position(self, *args):
|
||||
position = self.player.position()
|
||||
def update_position(self, position):
|
||||
if position >= 0:
|
||||
self.currentTimeLabel.setText(hhmmss(position))
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
|
||||
@@ -18,10 +18,9 @@ alien bugs (B'ug) but they could just as easily be anything else.
|
||||
|
||||

|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
|
||||
## Code notes
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
|
||||
@@ -5,7 +5,6 @@ everything. Supports file loading, saving and printing.
|
||||
|
||||

|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
@@ -125,6 +125,7 @@ class MainWindow(QMainWindow):
|
||||
def file_open(self):
|
||||
path, _ = QFileDialog.getOpenFileName(self, "Open file", "", "Text documents (*.txt);All files (*.*)")
|
||||
|
||||
if path:
|
||||
try:
|
||||
with open(path, 'rU') as f:
|
||||
text = f.read()
|
||||
@@ -142,22 +143,19 @@ class MainWindow(QMainWindow):
|
||||
# If we do not have a path, we need to use Save As.
|
||||
return self.file_saveas()
|
||||
|
||||
text = self.editor.toPlainText()
|
||||
try:
|
||||
with open(self.path, 'w') as f:
|
||||
f.write(text)
|
||||
|
||||
except Exception as e:
|
||||
self.dialog_critical(str(e))
|
||||
self._save_to_path(self.path)
|
||||
|
||||
def file_saveas(self):
|
||||
path, _ = QFileDialog.getSaveFileName(self, "Save file", "", "Text documents (*.txt);All files (*.*)")
|
||||
text = self.editor.toPlainText()
|
||||
|
||||
if not path:
|
||||
# If dialog is cancelled, will return ''
|
||||
return
|
||||
|
||||
self._save_to_path(path)
|
||||
|
||||
def _save_to_path(self, path):
|
||||
text = self.editor.toPlainText()
|
||||
try:
|
||||
with open(path, 'w') as f:
|
||||
f.write(text)
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
|
||||
@@ -8,7 +8,6 @@ are stored locally in a SQLite database.
|
||||
This app is very simple, but demonstrates creation of decoration-less windows in PyQt. Removing the window
|
||||
decorations removes the means to drag windows around, so we must re-implement this behaviour ourselves.
|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
@@ -1 +1,2 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
|
||||
@@ -17,10 +17,9 @@ which is pre-loaded with pictures of delicious pie.
|
||||
|
||||

|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
|
||||
## Code notes
|
||||
|
||||
|
||||
@@ -402,27 +402,14 @@ class Canvas(QLabel):
|
||||
else:
|
||||
self.active_color = self.secondary_color
|
||||
|
||||
# Convert to image for pixel-by-pixel reading.
|
||||
image = self.pixmap().toImage()
|
||||
w, h = image.width(), image.height()
|
||||
s = image.bits().asstring(w * h * 4)
|
||||
|
||||
x, y = e.x(), e.y()
|
||||
# Lookup the 3-byte value at our current location.
|
||||
i = (x + (y * w)) * 4
|
||||
target_color = s[i:i+3]
|
||||
|
||||
# Convert bytestring to 1byte pp. true/false for matching colour. True values
|
||||
# will be 255, non-matching 0. Simplifies the lookup in get_pixel and
|
||||
# comparison in the main loop giving slight performance increase.
|
||||
s = b''.join(b'\xff' if s[n:n+3] == target_color else b'\x00' for n in range(0, len(s), 4))
|
||||
|
||||
def get_pixel(x, y):
|
||||
i = (x + (y * w))
|
||||
return s[i]
|
||||
# Get our target color from origin.
|
||||
target_color = image.pixel(x,y)
|
||||
|
||||
have_seen = set()
|
||||
to_fill = []
|
||||
queue = [(x, y)]
|
||||
|
||||
def get_cardinal_points(have_seen, center_pos):
|
||||
@@ -439,17 +426,16 @@ class Canvas(QLabel):
|
||||
|
||||
return points
|
||||
|
||||
while queue:
|
||||
x, y = queue.pop()
|
||||
if get_pixel(x, y): # 255 for a match (True) or 0 for a miss (False)
|
||||
to_fill.append((x,y))
|
||||
queue.extend(get_cardinal_points(have_seen, (x, y)))
|
||||
|
||||
if to_fill:
|
||||
# Now we have the points, perform the fill.
|
||||
# Now perform the search and fill.
|
||||
p = QPainter(self.pixmap())
|
||||
p.setPen(QPen(self.active_color))
|
||||
p.drawPoints(*[QPoint(*xy) for xy in to_fill])
|
||||
|
||||
while queue:
|
||||
x, y = queue.pop()
|
||||
if image.pixel(x, y) == target_color:
|
||||
p.drawPoint(QPoint(x, y))
|
||||
queue.extend(get_cardinal_points(have_seen, (x, y)))
|
||||
|
||||
self.update()
|
||||
|
||||
# Dropper events
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
|
||||
@@ -59,3 +59,8 @@ Note that the linked repository contains some custom art on ace cards which may
|
||||
was not used.
|
||||
|
||||
Icons used in the application are by [Yusuke Kamiyaman](http://p.yusukekamiyamane.com/).
|
||||
|
||||
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
@@ -1 +1,2 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Translatarrrr — Instant translation from any language to Pirate
|
||||
|
||||
A translator from any language (supported by Goolge translate) to pirate.
|
||||
A translator from any language (supported by Google translate) to pirate.
|
||||
This uses a remote API from http://api.funtranslations.com for English
|
||||
to Pirate translation, and a unofficial Python wrapper around Google translate
|
||||
for other languages to English.
|
||||
@@ -19,9 +19,6 @@ pay for an API key to get more.
|
||||
|
||||
This is, therefore, very useless.
|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
|
||||
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
requests>=2.0.0
|
||||
|
||||
@@ -14,10 +14,9 @@ Simply drag and drop your .zip file onto the cat to fill it up with Pez.
|
||||
|
||||
The press the cat's head to release the Pez.
|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
|
||||
|
||||
## Code notes
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
|
||||
@@ -56,7 +56,7 @@ class UnzipWorker(QRunnable):
|
||||
items = self.zipfile.infolist()
|
||||
total_n = len(items)
|
||||
|
||||
for n, item in enumerate(items):
|
||||
for n, item in enumerate(items, 1):
|
||||
if not any(item.filename.startswith(p) for p in EXCLUDE_PATHS):
|
||||
self.zipfile.extract(item)
|
||||
|
||||
@@ -99,7 +99,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
# Perform the unzip
|
||||
self.threadpool.start(self.worker)
|
||||
self.worker = None # Remove the worker so it is not double-triggere.
|
||||
self.worker = None # Remove the worker so it is not double-triggered.
|
||||
|
||||
elif e.button() == Qt.RightButton:
|
||||
pass # Open a new zip.
|
||||
@@ -201,11 +201,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
)
|
||||
|
||||
def unzip_finished(self):
|
||||
self.update_progress(1)
|
||||
pass
|
||||
|
||||
def unzip_error(self, err):
|
||||
exctype, value, traceback = err
|
||||
|
||||
self.update_progress(1) # Reset the Pez bar.
|
||||
|
||||
dlg = QMessageBox(self)
|
||||
dlg.setText(traceback)
|
||||
dlg.setIcon(QMessageBox.Critical)
|
||||
|
||||
@@ -5,10 +5,9 @@ weather and forecast API from https://openweathermap.org/
|
||||
|
||||

|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
|
||||
## Other licenses
|
||||
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
requests>=2.0.0
|
||||
|
||||
@@ -12,10 +12,9 @@ Saves and opens HTML format documents.
|
||||
|
||||

|
||||
|
||||
> If you think this example app is neat and want to learn more about
|
||||
PyQt in general, [take a look at my ebook & online course
|
||||
"Create Simple GUI Applications"](https://martinfitzpatrick.name/create-simple-gui-applications)
|
||||
which covers everything you need to know to start building your own applications with PyQt.
|
||||
> If you think this app is neat and want to learn more about
|
||||
PyQt in general, take a look at my [free PyQt tutorials](https://www.learnpyqt.com)
|
||||
which cover everything you need to know to start building your own applications with PyQt.
|
||||
|
||||
## Other licenses
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
PyQt5>=5.6
|
||||
sip
|
||||
|
||||
@@ -68,7 +68,6 @@ class MainWindow(QMainWindow):
|
||||
layout = QVBoxLayout()
|
||||
self.editor = TextEdit()
|
||||
# Setup the QTextEdit editor configuration
|
||||
self.editor.setAcceptRichText(False)
|
||||
self.editor.setAutoFormatting(QTextEdit.AutoAll)
|
||||
self.editor.selectionChanged.connect(self.update_format)
|
||||
# Initialize default font size.
|
||||
|
||||
Reference in New Issue
Block a user