PyQt5 --> PyQt6 💚

This commit is contained in:
Dpeta 2022-06-27 04:18:37 +02:00
parent 0eeebe349d
commit 2576be41aa
22 changed files with 940 additions and 934 deletions

View file

@ -1,6 +1,11 @@
# Changelog
(This document uses YYYY-MM-DD)
## [v2.4] - 2022-06-27
### Changed
- Transitioned from PyQt5 to PyQt6 🌈
## [v2.3.1] - 2022-06-23
### Added

View file

@ -7,8 +7,8 @@ This repository builds on (and was mirrored from!) pesterchum-karxi + Hydrotherm
Check out [CHANGELOG.md] file to see what's changed!
[CHANGELOG.md]: https://github.com/Dpeta/pesterchum-alt-servers/blob/py3_pyqt5/CHANGELOG.md
[TODO.md]: https://github.com/Dpeta/pesterchum-alt-servers/blob/py3_pyqt5/TODO.md
[CHANGELOG.md]: https://github.com/Dpeta/pesterchum-alt-servers/blob/main/CHANGELOG.md
[TODO.md]: https://github.com/Dpeta/pesterchum-alt-servers/blob/main/TODO.md
## GUIDES
@ -20,9 +20,9 @@ I'd highly recommend you take a look at the following files if you're new to Pes
Guides for python quirks and themes are also in the [docs] folder. If you want to set up a gradient quirk you should take a look at [these guides][gradient-guide].
[gradient-guide]: https://paste.0xfc.de/?e60df5a155e93583#AmcgN9cRnCcBycmVMvw6KJ1YLKPXGbaSzZLbgAhoNCQD
[trollquirks.mkdn]: https://github.com/Dpeta/pesterchum-alt-servers/blob/py3_pyqt5/docs/trollquirks.mkdn
[README-pesterchum.mkdn]: https://github.com/Dpeta/pesterchum-alt-servers/blob/py3_pyqt5/docs/README-pesterchum.mkdn
[docs]: https://github.com/Dpeta/pesterchum-alt-servers/tree/py3_pyqt5/docs/
[trollquirks.mkdn]: https://github.com/Dpeta/pesterchum-alt-servers/blob/main/docs/trollquirks.mkdn
[README-pesterchum.mkdn]: https://github.com/Dpeta/pesterchum-alt-servers/blob/main/docs/README-pesterchum.mkdn
[docs]: https://github.com/Dpeta/pesterchum-alt-servers/tree/main/docs/
## INSTALLATION
1. Download the appropriate release for your platform and architecture from [releases][releases].
@ -50,7 +50,7 @@ Pesterchum is a Python script. This means that as long as you have Python instal
### REQUIREMENTS
- [Python 3]
- [PyQt5>=5.15]
- [PyQt6]
- [pygame] (Only required for audio, Pesterchum will probably still run without it.)
### WALKTHROUGH
@ -60,17 +60,17 @@ Pesterchum is a Python script. This means that as long as you have Python instal
- Some platforms, mostly Linux and macOS, might require you to run ``python3`` instead of ``python``. Some old installations still have Python 2 available under ``python``.
- On Linux it's better to install Python & pip via your package manager.
- On macOS it's also possible to install (a more recent version of) Python via [Brew](https://brew.sh/).
2. Install Pesterchum's dependencies with pip, run: ``python -m pip install PyQt5 pygame``
2. Install Pesterchum's dependencies with pip, run: ``python -m pip install PyQt6 pygame``
- If this fails, try running ``python -m pip install -U pip setuptools wheel`` to update pip, setuptools & wheel and then trying again.
3. Download [this repository's source](https://github.com/Dpeta/pesterchum-alt-servers/archive/refs/heads/py3_pyqt5.zip), or choose the "Source Code" option on any release, and extract the archive to a folder of your choice.
3. Download [this repository's source](https://github.com/Dpeta/pesterchum-alt-servers/archive/refs/heads/main.zip), or choose the "Source Code" option on any release, and extract the archive to a folder of your choice.
4. Navigate your terminal to the folder you chose with ``cd /folder/you/chose``.
- For example, if you extracted it to your documents on Windows, run ``cd C:\Users\user\Documents\pesterchum-alt-servers-py3_pyqt5``.
- Windows's cd command requires the /d flag to navigate to a different drive. (``cd D:\pesterchum-alt-servers-py3_pyqt5``)
- For example, if you extracted it to your documents on Windows, run ``cd C:\Users\user\Documents\pesterchum-alt-servers-main``.
- Windows's cd command requires the /d flag to navigate to a different drive. (``cd D:\pesterchum-alt-servers-main``)
5. Run Pesterchum by running either ``pesterchum.py`` or ``python pesterchum.py``.
[Python 3]: https://www.python.org/downloads/
[pip]: https://pypi.org/project/pip/
[PyQt5>=5.15]: https://pypi.org/project/PyQt5/
[PyQt6]: https://pypi.org/project/PyQt6/
[pygame]: https://pypi.org/project/pygame/
## FREEZE / BUILD

View file

@ -9,7 +9,7 @@ import datetime
import logging
import logging.config
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
import dataobjs
#import generic
@ -440,23 +440,23 @@ class ConsoleText(QtWidgets.QTextEdit):
# should.
# karxi: Test for tab changing?
if self.window().text.input:
if event.key() not in (QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown,
QtCore.Qt.Key_Up, QtCore.Qt.Key_Down):
if event.key() not in (QtCore.Key.Qt.Key_PageUp, QtCore.Qt.Key.Key_PageDown,
QtCore.Qt.Key.Key_Up, QtCore.Qt.Key.Key_Down):
self.window().text.input.keyPressEvent(event)
super(ConsoleText, self).keyPressEvent(event)
def mousePressEvent(self, event):
if event.button() == QtCore.Qt.LeftButton:
if event.button() == QtCore.Qt.MouseButton.LeftButton:
url = self.anchorAt(event.pos())
if url != "":
# Skip memo/handle recognition
# NOTE: Ctrl+Click copies the URL. Maybe it should select it?
if event.modifiers() == QtCore.Qt.ControlModifier:
if event.modifiers() == QtCore.Qt.KeyboardModifier.ControlModifier:
QtWidgets.QApplication.clipboard().setText(url)
else:
# This'll probably be removed. May change the lexer out.
QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode))
QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.ParsingMode.TolerantMode))
super(ConsoleText, self).mousePressEvent(event)
@ -464,14 +464,14 @@ class ConsoleText(QtWidgets.QTextEdit):
# Change our cursor when we roll over links (anchors).
super(ConsoleText, self).mouseMoveEvent(event)
if self.anchorAt(event.pos()):
if self.viewport().cursor().shape != QtCore.Qt.PointingHandCursor:
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
if self.viewport().cursor().shape != QtCore.Qt.CursorShape.PointingHandCursor:
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
else:
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.IBeamCursor))
def contextMenuEvent(self, event):
textMenu = self.createStandardContextMenu()
textMenu.exec_(event.globalPos())
textMenu.exec(event.globalPos())
class ConsoleInput(QtWidgets.QLineEdit):
@ -504,16 +504,16 @@ class ConsoleInput(QtWidgets.QLineEdit):
# messing around in the console? Hm.
parent.mainwindow.idler.time = 0
if evtkey == QtCore.Qt.Key_Up:
if evtkey == QtCore.Qt.Key.Key_Up:
text = str(self.text())
next = parent.text.history.next(text)
if next is not None:
self.setText(next)
elif evtkey == QtCore.Qt.Key_Down:
elif evtkey == QtCore.Qt.Key.Key_Down:
prev = parent.text.history.prev()
if prev is not None:
self.setText(prev)
elif evtkey in (QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown):
elif evtkey in (QtCore.Qt.Key.Key_PageUp, QtCore.Qt.Key.Key_PageDown):
parent.text.area.keyPressEvent(event)
else:
super(ConsoleInput, self).keyPressEvent(event)

115
convo.py
View file

@ -7,7 +7,7 @@ PchumLog = logging.getLogger('pchumLogger')
from string import Template
from time import strftime
from datetime import datetime, timedelta
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
from dataobjs import PesterHistory
from parsetools import convertTags, lexMessage, mecmd, colorBegin, colorEnd, \
@ -19,8 +19,8 @@ from pnc.dep.attrdict import AttrDict
class PesterTabWindow(QtWidgets.QFrame):
def __init__(self, mainwindow, parent=None, convo="convo"):
super(PesterTabWindow, self).__init__(parent)
self.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
self.setFocusPolicy(QtCore.Qt.ClickFocus)
self.setAttribute(QtCore.Qt.WidgetAttribute.WA_QuitOnClose, False)
self.setFocusPolicy(QtCore.Qt.FocusPolicy.ClickFocus)
self.mainwindow = mainwindow
self.tabs = QtWidgets.QTabBar(self)
@ -31,19 +31,19 @@ class PesterTabWindow(QtWidgets.QFrame):
self.tabs.tabMoved[int, int].connect(self.tabMoved)
self.shortcuts = AttrDict()
self.shortcuts.tabNext = QtWidgets.QShortcut(
self.shortcuts.tabNext = QtGui.QShortcut(
QtGui.QKeySequence('Ctrl+j'), self,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.shortcuts.tabLast = QtWidgets.QShortcut(
context=QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
self.shortcuts.tabLast = QtGui.QShortcut(
QtGui.QKeySequence('Ctrl+k'), self,
context=QtCore.Qt.WidgetWithChildrenShortcut)
context=QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
# Note that we use reversed keys here.
self.shortcuts.tabUp = QtWidgets.QShortcut(
self.shortcuts.tabUp = QtGui.QShortcut(
QtGui.QKeySequence('Ctrl+PgDown'), self,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.shortcuts.tabDn = QtWidgets.QShortcut(
context=QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
self.shortcuts.tabDn = QtGui.QShortcut(
QtGui.QKeySequence('Ctrl+PgUp'), self,
context=QtCore.Qt.WidgetWithChildrenShortcut)
context=QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
self.shortcuts.tabNext.activated.connect(self.nudgeTabNext)
self.shortcuts.tabUp.activated.connect(self.nudgeTabNext)
@ -106,8 +106,8 @@ class PesterTabWindow(QtWidgets.QFrame):
# TODO: Clean this up. Our text areas now call this.
keypress = event.key()
mods = event.modifiers()
if ((mods & QtCore.Qt.ControlModifier) and
keypress == QtCore.Qt.Key_Tab):
if ((mods & QtCore.Qt.KeyboardModifier.ControlModifier) and
keypress == QtCore.Qt.Key.Key_Tab):
handles = list(self.convos.keys())
waiting = self.mainwindow.waitingMessages.waitingHandles()
waitinghandles = list(set(handles) & set(waiting))
@ -125,9 +125,9 @@ class PesterTabWindow(QtWidgets.QFrame):
def nudgeTabIndex(self, direction):
# Inverted controls. Might add an option for this if people want
# it.
#~if keypress == QtCore.Qt.Key_PageDown:
#~if keypress == QtCore.Qt.Key.Key_PageDown:
#~ direction = 1
#~elif keypress == QtCore.Qt.Key_PageUp:
#~elif keypress == QtCore.Qt.Key.Key_PageUp:
#~ direction = -1
# ...Processing...
tabs = self.tabs
@ -152,7 +152,7 @@ class PesterTabWindow(QtWidgets.QFrame):
tabs.setCurrentIndex(nind)
def contextMenuEvent(self, event):
#~if event.reason() == QtGui.QContextMenuEvent.Mouse:
#~if event.reason() == QtGui.QContextMenuEvent.Reason.Mouse:
tabi = self.tabs.tabAt(event.pos())
if tabi < 0:
tabi = self.tabs.currentIndex()
@ -224,7 +224,7 @@ class PesterTabWindow(QtWidgets.QFrame):
def initTheme(self, theme):
self.resize(*theme["convo/size"])
self.setStyleSheet(theme["convo/tabwindow/style"])
self.tabs.setShape(theme["convo/tabs/tabstyle"])
self.tabs.setShape(QtWidgets.QTabBar.Shape(theme["convo/tabs/tabstyle"]))
self.tabs.setStyleSheet("QTabBar::tab{ %s } QTabBar::tab:selected { %s }" % (theme["convo/tabs/style"], theme["convo/tabs/selectedstyle"]))
def changeTheme(self, theme):
@ -314,12 +314,13 @@ class PesterMovie(QtGui.QMovie):
if text.hasTabs:
i = text.tabobject.tabIndices[text.parent().title()]
if text.tabobject.tabs.currentIndex() == i:
text.document().addResource(QtGui.QTextDocument.ImageResource,
text.document().addResource(QtGui.QTextDocument.ResourceType.ImageResource.value,
text.urls[movie], movie.currentPixmap())
text.setLineWrapColumnOrWidth(text.lineWrapColumnOrWidth())
else:
text.document().addResource(QtGui.QTextDocument.ImageResource,
text.urls[movie], movie.currentPixmap())
text.document().addResource(QtGui.QTextDocument.ResourceType.ImageResource.value,
text.urls[movie],
movie.currentPixmap())
text.setLineWrapColumnOrWidth(text.lineWrapColumnOrWidth())
@ -396,7 +397,7 @@ class PesterText(QtWidgets.QTextEdit):
if self.mainwindow.config.animations():
for m in self.urls:
if convertTags(lexmsg).find(self.urls[m].toString()) != -1:
if m.state() == QtGui.QMovie.NotRunning:
if m.state() == QtGui.QMovie.MovieState.NotRunning:
m.start()
if self.parent().mainwindow.config.showTimeStamps():
if self.parent().mainwindow.config.time12Format():
@ -486,8 +487,8 @@ class PesterText(QtWidgets.QTextEdit):
def keyPressEvent(self, event):
# First parent is the PesterConvo containing this.
# Second parent is the PesterTabWindow containing *it*.
pass_to_super = (QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown,
QtCore.Qt.Key_Up, QtCore.Qt.Key_Down)
pass_to_super = (QtCore.Qt.Key.Key_PageUp, QtCore.Qt.Key.Key_PageDown,
QtCore.Qt.Key.Key_Up, QtCore.Qt.Key.Key_Down)
parent = self.parent()
key = event.key()
#keymods = event.modifiers()
@ -499,7 +500,7 @@ class PesterText(QtWidgets.QTextEdit):
super(PesterText, self).keyPressEvent(event)
def mousePressEvent(self, event):
if event.button() == QtCore.Qt.LeftButton:
if event.button() == QtCore.Qt.MouseButton.LeftButton:
url = self.anchorAt(event.pos())
if url != "":
if url[0] == "#" and url != "#pesterchum":
@ -508,22 +509,22 @@ class PesterText(QtWidgets.QTextEdit):
handle = str(url[1:])
self.parent().mainwindow.newConversation(handle)
else:
if event.modifiers() == QtCore.Qt.ControlModifier:
if event.modifiers() == QtCore.Qt.KeyboardModifier.ControlModifier:
QtWidgets.QApplication.clipboard().setText(url)
else:
QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode))
QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.ParsingMode.TolerantMode))
QtWidgets.QTextEdit.mousePressEvent(self, event)
def mouseMoveEvent(self, event):
QtWidgets.QTextEdit.mouseMoveEvent(self, event)
if self.anchorAt(event.pos()):
if self.viewport().cursor().shape != QtCore.Qt.PointingHandCursor:
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
if self.viewport().cursor().shape != QtCore.Qt.CursorShape.PointingHandCursor:
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
else:
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.IBeamCursor))
def contextMenuEvent(self, event):
textMenu = self.createStandardContextMenu()
textMenu.exec_(event.globalPos())
textMenu.exec(event.globalPos())
class PesterInput(QtWidgets.QLineEdit):
stylesheet_path = "convo/input/style"
@ -544,16 +545,16 @@ class PesterInput(QtWidgets.QLineEdit):
self.parent().textArea.textCursor().clearSelection()
super(PesterInput, self).focusInEvent(event)
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Up:
if event.key() == QtCore.Qt.Key.Key_Up:
text = str(self.text())
next = self.parent().history.next(text)
if next is not None:
self.setText(next)
elif event.key() == QtCore.Qt.Key_Down:
elif event.key() == QtCore.Qt.Key.Key_Down:
prev = self.parent().history.prev()
if prev is not None:
self.setText(prev)
elif event.key() in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]:
elif event.key() in [QtCore.Qt.Key.Key_PageUp, QtCore.Qt.Key.Key_PageDown]:
self.parent().textArea.keyPressEvent(event)
self.parent().mainwindow.idler.time = 0
super(PesterInput, self).keyPressEvent(event)
@ -561,9 +562,9 @@ class PesterInput(QtWidgets.QLineEdit):
class PesterConvo(QtWidgets.QFrame):
def __init__(self, chum, initiated, mainwindow, parent=None):
super(PesterConvo, self).__init__(parent)
self.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
self.setAttribute(QtCore.Qt.WidgetAttribute.WA_QuitOnClose, False)
self.setObjectName(chum.handle)
self.setFocusPolicy(QtCore.Qt.ClickFocus)
self.setFocusPolicy(QtCore.Qt.FocusPolicy.ClickFocus)
self.chum = chum
self.mainwindow = mainwindow
theme = self.mainwindow.theme
@ -579,7 +580,7 @@ class PesterConvo(QtWidgets.QFrame):
self.chumLabel.setAlignment(self.aligndict["h"][self.mainwindow.theme["convo/chumlabel/align/h"]] | self.aligndict["v"][self.mainwindow.theme["convo/chumlabel/align/v"]])
self.chumLabel.setMaximumHeight(self.mainwindow.theme["convo/chumlabel/maxheight"])
self.chumLabel.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"])
self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding))
self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.MinimumExpanding))
self.textArea = PesterText(self.mainwindow.theme, self)
self.textInput = PesterInput(self.mainwindow.theme, self)
self.textInput.setFocus()
@ -599,21 +600,21 @@ class PesterConvo(QtWidgets.QFrame):
self.optionsMenu = QtWidgets.QMenu(self)
self.optionsMenu.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
self.addChumAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
self.addChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
self.addChumAction.triggered.connect(self.addThisChum)
self.blockAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self)
self.blockAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self)
self.blockAction.triggered.connect(self.blockThisChum)
self.quirksOff = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self)
self.quirksOff = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self)
self.quirksOff.setCheckable(True)
self.quirksOff.toggled[bool].connect(self.toggleQuirks)
self.oocToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self)
self.oocToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self)
self.oocToggle.setCheckable(True)
self.oocToggle.toggled[bool].connect(self.toggleOOC)
self.unblockchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self)
self.unblockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self)
self.unblockchum.triggered.connect(self.unblockChumSlot)
self.reportchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self)
self.reportchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self)
self.reportchum.triggered.connect(self.reportThisChum)
self.logchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self)
self.logchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self)
self.logchum.triggered.connect(self.openChumLogs)
# For this, we'll want to use setChecked to toggle these so they match
@ -626,25 +627,25 @@ class PesterConvo(QtWidgets.QFrame):
# Theme support :3c
#if self.mainwindow.theme.has_key("main/menus/rclickchumlist/beeponmessage"):
try:
self._beepToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/beeponmessage"], self)
self._beepToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/beeponmessage"], self)
except:
self._beepToggle = QtWidgets.QAction("BEEP ON MESSAGE", self)
self._beepToggle = QtGui.QAction("BEEP ON MESSAGE", self)
self._beepToggle.setCheckable(True)
self._beepToggle.toggled[bool].connect(self.toggleBeep)
#if self.mainwindow.theme.has_key("main/menus/rclickchumlist/flashonmessage"):
try:
self._flashToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/flashonmessage"], self)
self._flashToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/flashonmessage"], self)
except:
self._flashToggle = QtWidgets.QAction("FLASH ON MESSAGE", self)
self._flashToggle = QtGui.QAction("FLASH ON MESSAGE", self)
self._flashToggle.setCheckable(True)
self._flashToggle.toggled[bool].connect(self.toggleFlash)
#if self.mainwindow.theme.has_key("main/menus/rclickchumlist/mutenotifications"):
try:
self._muteToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/mutenotifications"], self)
self._muteToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/mutenotifications"], self)
except:
self._muteToggle = QtWidgets.QAction("MUTE NOTIFICATIONS", self)
self._muteToggle = QtGui.QAction("MUTE NOTIFICATIONS", self)
self._muteToggle.setCheckable(True)
self._muteToggle.toggled[bool].connect(self.toggleMute)
@ -817,7 +818,7 @@ class PesterConvo(QtWidgets.QFrame):
self.parent().showChat(self.title())
self.raiseChat()
def contextMenuEvent(self, event):
if event.reason() == QtGui.QContextMenuEvent.Mouse:
if event.reason() == QtGui.QContextMenuEvent.Reason.Mouse:
self.optionsMenu.popup(event.globalPos())
def closeEvent(self, event):
self.mainwindow.waitingMessages.messageAnswered(self.title())
@ -844,7 +845,7 @@ class PesterConvo(QtWidgets.QFrame):
self.chumLabel.setAlignment(self.aligndict["h"][self.mainwindow.theme["convo/chumlabel/align/h"]] | self.aligndict["v"][self.mainwindow.theme["convo/chumlabel/align/v"]])
self.chumLabel.setMaximumHeight(self.mainwindow.theme["convo/chumlabel/maxheight"])
self.chumLabel.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"])
self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding))
self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Expanding))
self.quirksOff.setText(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"])
self.addChumAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/addchum"])
self.blockAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"])
@ -929,12 +930,12 @@ class PesterConvo(QtWidgets.QFrame):
messageSent = QtCore.pyqtSignal('QString', 'QString')
windowClosed = QtCore.pyqtSignal('QString')
aligndict = {"h": {"center": QtCore.Qt.AlignHCenter,
"left": QtCore.Qt.AlignLeft,
"right": QtCore.Qt.AlignRight },
"v": {"center": QtCore.Qt.AlignVCenter,
"top": QtCore.Qt.AlignTop,
"bottom": QtCore.Qt.AlignBottom } }
aligndict = {"h": {"center": QtCore.Qt.AlignmentFlag.AlignHCenter,
"left": QtCore.Qt.AlignmentFlag.AlignLeft,
"right": QtCore.Qt.AlignmentFlag.AlignRight },
"v": {"center": QtCore.Qt.AlignmentFlag.AlignVCenter,
"top": QtCore.Qt.AlignmentFlag.AlignTop,
"bottom": QtCore.Qt.AlignmentFlag.AlignBottom } }
# the import is way down here to avoid recursive imports
from logviewer import PesterLogViewer

View file

@ -4,7 +4,7 @@ import ostools
_datadir = ostools.getDataDir()
logging.config.fileConfig(_datadir + "logging.ini")
PchumLog = logging.getLogger('pchumLogger')
from PyQt5 import QtGui
from PyQt6 import QtGui
from datetime import datetime
import re
import random

View file

@ -1,4 +1,4 @@
from PyQt5 import QtGui, QtWidgets
from PyQt6 import QtGui, QtWidgets
from datetime import timedelta
class mysteryTime(timedelta):
@ -44,7 +44,7 @@ class PesterIcon(QtGui.QIcon):
class RightClickList(QtWidgets.QListWidget):
def contextMenuEvent(self, event):
#fuckin Qt <--- I feel that </3
if event.reason() == QtGui.QContextMenuEvent.Mouse:
if event.reason() == QtGui.QContextMenuEvent.Reason.Mouse:
listing = self.itemAt(event.pos())
self.setCurrentItem(listing)
optionsMenu = self.getOptionsMenu()
@ -55,7 +55,7 @@ class RightClickList(QtWidgets.QListWidget):
class RightClickTree(QtWidgets.QTreeWidget):
def contextMenuEvent(self, event):
if event.reason() == QtGui.QContextMenuEvent.Mouse:
if event.reason() == QtGui.QContextMenuEvent.Reason.Mouse:
listing = self.itemAt(event.pos())
self.setCurrentItem(listing)
optionsMenu = self.getOptionsMenu()
@ -95,8 +95,8 @@ class MultiTextDialog(QtWidgets.QDialog):
self.setLayout(layout_0)
def getText(self):
r = self.exec_()
if r == QtWidgets.QDialog.Accepted:
r = self.exec()
if r == QtWidgets.QDialog.DialogCode.Accepted:
retval = {}
for (name, widget) in self.inputs.items():
retval[name] = str(widget.text())
@ -128,7 +128,7 @@ class MovingWindow(QtWidgets.QFrame):
if event.button() == 1:
self.moving = event.globalPos() - self.pos()
except AttributeError as e:
print("PyQt5 <= 5.14?")
print("PyQt6 <= 5.14?")
print(str(e))
if event.button() == 1:
self.moving = event.globalPos() - self.pos()

2
irc.py
View file

@ -5,7 +5,7 @@ import random
import time
import json
from PyQt5 import QtCore, QtGui
from PyQt6 import QtCore, QtGui
import ostools
from mood import Mood

View file

@ -3,7 +3,7 @@ import codecs
import re
import ostools
from time import strftime, strptime
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
from generic import RightClickList, RightClickTree
from parsetools import convertTags
from convo import PesterText
@ -17,7 +17,7 @@ class PesterLogSearchInput(QtWidgets.QLineEdit):
def keyPressEvent(self, event):
QtWidgets.QLineEdit.keyPressEvent(self, event)
if hasattr(self.parent(), 'textArea'):
if event.key() == QtCore.Qt.Key_Return:
if event.key() == QtCore.Qt.Key.Key_Return:
self.parent().logSearch(self.text())
if self.parent().textArea.find(self.text()):
self.parent().textArea.ensureCursorVisible()
@ -29,8 +29,8 @@ class PesterLogHighlighter(QtGui.QSyntaxHighlighter):
QtGui.QSyntaxHighlighter.__init__(self, parent)
self.searchTerm = ""
self.hilightstyle = QtGui.QTextCharFormat()
self.hilightstyle.setBackground(QtGui.QBrush(QtCore.Qt.green))
self.hilightstyle.setForeground(QtGui.QBrush(QtCore.Qt.black))
self.hilightstyle.setBackground(QtGui.QBrush(QtCore.Qt.GlobalColor.green))
self.hilightstyle.setForeground(QtGui.QBrush(QtCore.Qt.GlobalColor.black))
def highlightBlock(self, text):
for i in range(0, len(text)-(len(self.searchTerm)-1)):
if str(text[i:i+len(self.searchTerm)]).lower() == str(self.searchTerm).lower():
@ -97,7 +97,7 @@ class PesterLogUserSelect(QtWidgets.QDialog):
return self.chumsBox.currentItem()
def logSearch(self, search):
found = self.chumsBox.findItems(search, QtCore.Qt.MatchStartsWith)
found = self.chumsBox.findItems(search, QtCore.Qt.MatchFlag.MatchStartsWith)
if len(found) > 0 and len(found) < self.chumsBox.count():
self.chumsBox.setCurrentItem(found[0])
@ -121,7 +121,7 @@ class PesterLogUserSelect(QtWidgets.QDialog):
@QtCore.pyqtSlot()
def openDir(self):
QtGui.QDesktopServices.openUrl(QtCore.QUrl("file:///" + os.path.join(_datadir, "logs"), QtCore.QUrl.TolerantMode))
QtGui.QDesktopServices.openUrl(QtCore.QUrl("file:///" + os.path.join(_datadir, "logs"), QtCore.QUrl.ParsingMode.TolerantMode))
class PesterLogViewer(QtWidgets.QDialog):
def __init__(self, chum, config, theme, parent):
@ -217,7 +217,7 @@ class PesterLogViewer(QtWidgets.QDialog):
self.ok.clicked.connect(self.reject)
layout_ok = QtWidgets.QHBoxLayout()
layout_ok.addWidget(self.ok)
layout_ok.setAlignment(self.ok, QtCore.Qt.AlignRight)
layout_ok.setAlignment(self.ok, QtCore.Qt.AlignmentFlag.AlignRight)
layout_logs = QtWidgets.QHBoxLayout()
layout_logs.addWidget(self.tree)
@ -246,7 +246,7 @@ class PesterLogViewer(QtWidgets.QDialog):
cline = re.sub("\[color=(#.{6})]", r"<c=\1>", cline)
self.textArea.append(convertTags(cline))
textCur = self.textArea.textCursor()
textCur.movePosition(1)
#textCur.movePosition(1)
self.textArea.setTextCursor(textCur)
self.instructions.setText("Pesterlog with " +self.chum+ " on " + self.fileToTime(str(fname)))
@ -278,19 +278,19 @@ class PesterLogText(PesterText):
handle = str(url[1:])
self.parent().parent.newConversation(handle)
else:
QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode))
QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.ParsingMode.TolerantMode))
QtWidgets.QTextEdit.mousePressEvent(self, event)
def mouseMoveEvent(self, event):
QtWidgets.QTextEdit.mouseMoveEvent(self, event)
if self.anchorAt(event.pos()):
if self.viewport().cursor().shape != QtCore.Qt.PointingHandCursor:
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
if self.viewport().cursor().shape != QtCore.Qt.CursorShape.PointingHandCursor:
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
else:
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.IBeamCursor))
def contextMenuEvent(self, event):
textMenu = self.createStandardContextMenu()
a = textMenu.actions()
a[0].setText("Copy Plain Text")
a[0].setShortcut(self.tr("Ctrl+C"))
textMenu.exec_(event.globalPos())
textMenu.exec(event.globalPos())

View file

@ -10,7 +10,7 @@ import os
import sys
import re
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
import ostools
from quirks import ScriptQuirks

View file

@ -4,7 +4,7 @@ import re
from string import Template
from datetime import timedelta, datetime
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
import ostools
import parsetools
@ -302,7 +302,7 @@ class MemoText(PesterText):
if self.mainwindow.config.animations():
for m in self.urls:
if convertTags(lexmsg).find(self.urls[m].toString()) != -1:
if m.state() == QtGui.QMovie.NotRunning:
if m.state() == QtGui.QMovie.MovieState.NotRunning:
m.start()
chumdb = window.chumdb
if chum is not me: # SO MUCH WH1T3SP4C3 >:]
@ -375,14 +375,14 @@ class PesterMemo(PesterConvo):
# TODO: Clean up inheritance between these!! The inits are ugly.
def __init__(self, channel, timestr, mainwindow, parent=None):
QtWidgets.QFrame.__init__(self, parent)
self.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
self.setAttribute(QtCore.Qt.WidgetAttribute.WA_QuitOnClose, False)
self.channel = channel
self.setObjectName(self.channel)
self.mainwindow = mainwindow
self.time = TimeTracker(txt2delta(timestr))
self.setWindowTitle(channel)
self.channelLabel = QtWidgets.QLabel(self)
self.channelLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding))
self.channelLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Expanding))
self.textArea = MemoText(self.mainwindow.theme, self)
self.textInput = MemoInput(self.mainwindow.theme, self)
@ -395,19 +395,19 @@ class PesterMemo(PesterConvo):
self.userlist = RightClickList(self)
self.userlist.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding))
self.userlist.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding))
self.userlist.optionsMenu = QtWidgets.QMenu(self)
self.pesterChumAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self)
self.pesterChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self)
self.pesterChumAction.triggered.connect(self.newPesterSlot)
self.addchumAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
self.addchumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
self.addchumAction.triggered.connect(self.addChumSlot)
self.banuserAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/banuser"], self)
self.banuserAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/banuser"], self)
self.banuserAction.triggered.connect(self.banSelectedUser)
self.opAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/opuser"], self)
self.opAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/opuser"], self)
self.opAction.triggered.connect(self.opSelectedUser)
self.voiceAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/voiceuser"], self)
self.voiceAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/voiceuser"], self)
self.voiceAction.triggered.connect(self.voiceSelectedUser)
self.quirkDisableAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirkkill"], self)
self.quirkDisableAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirkkill"], self)
self.quirkDisableAction.triggered.connect(self.killQuirkUser)
self.userlist.optionsMenu.addAction(self.pesterChumAction)
self.userlist.optionsMenu.addAction(self.addchumAction)
@ -416,38 +416,38 @@ class PesterMemo(PesterConvo):
self.optionsMenu = QtWidgets.QMenu(self)
self.optionsMenu.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) # So it doesn't inherit the memo's background image.
# Fixes floating "PESTERLOG:"
self.oocToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self)
self.oocToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self)
self.oocToggle.setCheckable(True)
self.oocToggle.toggled[bool].connect(self.toggleOOC)
self.quirksOff = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self)
self.quirksOff = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self)
self.quirksOff.setCheckable(True)
self.quirksOff.toggled[bool].connect(self.toggleQuirks)
self.logchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self)
self.logchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self)
self.logchum.triggered.connect(self.openChumLogs)
self.invitechum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/invitechum"], self)
self.invitechum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/invitechum"], self)
self.invitechum.triggered.connect(self.inviteChums)
#if self.mainwindow.theme.has_key("main/menus/rclickchumlist/beeponmessage"):
try:
self._beepToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/beeponmessage"], self)
self._beepToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/beeponmessage"], self)
except:
self._beepToggle = QtWidgets.QAction("BEEP ON MESSAGE", self)
self._beepToggle = QtGui.QAction("BEEP ON MESSAGE", self)
self._beepToggle.setCheckable(True)
self._beepToggle.toggled[bool].connect(self.toggleBeep)
#if self.mainwindow.theme.has_key("main/menus/rclickchumlist/flashonmessage"):
try:
self._flashToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/flashonmessage"], self)
self._flashToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/flashonmessage"], self)
except:
self._flashToggle = QtWidgets.QAction("FLASH ON MESSAGE", self)
self._flashToggle = QtGui.QAction("FLASH ON MESSAGE", self)
self._flashToggle.setCheckable(True)
self._flashToggle.toggled[bool].connect(self.toggleFlash)
#if self.mainwindow.theme.has_key("main/menus/rclickchumlist/mutenotifications"):
try:
self._muteToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/mutenotifications"], self)
self._muteToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/mutenotifications"], self)
except:
self._muteToggle = QtWidgets.QAction("MUTE NOTIFICATIONS", self)
self._muteToggle = QtGui.QAction("MUTE NOTIFICATIONS", self)
self._muteToggle.setCheckable(True)
self._muteToggle.toggled[bool].connect(self.toggleMute)
@ -462,16 +462,16 @@ class PesterMemo(PesterConvo):
self.optionsMenu.addAction(self.invitechum)
self.chanModeMenu = QtWidgets.QMenu(self.mainwindow.theme["main/menus/rclickchumlist/memosetting"], self)
self.chanNoquirks = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memonoquirk"], self)
self.chanNoquirks = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memonoquirk"], self)
self.chanNoquirks.setCheckable(True)
self.chanNoquirks.toggled[bool].connect(self.noquirksChan)
self.chanHide = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memohidden"], self)
self.chanHide = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memohidden"], self)
self.chanHide.setCheckable(True)
self.chanHide.toggled[bool].connect(self.hideChan)
self.chanInvite = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memoinvite"], self)
self.chanInvite = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memoinvite"], self)
self.chanInvite.setCheckable(True)
self.chanInvite.toggled[bool].connect(self.inviteChan)
self.chanMod = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memomute"], self)
self.chanMod = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memomute"], self)
self.chanMod.setCheckable(True)
self.chanMod.toggled[bool].connect(self.modChan)
self.chanModeMenu.addAction(self.chanNoquirks)
@ -480,7 +480,7 @@ class PesterMemo(PesterConvo):
self.chanModeMenu.addAction(self.chanMod)
self.chanModeMenu.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) # BWAH BWAH FLOATING "PESTERLOG:"
self.timeslider = TimeSlider(QtCore.Qt.Horizontal, self)
self.timeslider = TimeSlider(QtCore.Qt.Orientation.Horizontal, self)
self.timeinput = TimeInput(self.timeslider, self)
self.timeinput.setText(timestr)
self.timeinput.setSlider()
@ -511,7 +511,7 @@ class PesterMemo(PesterConvo):
layout_1.addWidget(self.userlist)
# layout_1 = QtGui.QGridLayout()
# layout_1.addWidget(self.timeslider, 0, 1, QtCore.Qt.AlignHCenter)
# layout_1.addWidget(self.timeslider, 0, 1, QtCore.Qt.AlignmentFlag.AlignHCenter)
# layout_1.addWidget(self.timeinput, 1, 0, 1, 3)
layout_2 = QtWidgets.QHBoxLayout()
layout_2.addWidget(self.timeslider)
@ -582,7 +582,7 @@ class PesterMemo(PesterConvo):
def updateBlocked(self):
pass
def updateColor(self, handle, color):
chums = self.userlist.findItems(handle, QtCore.Qt.MatchFlags(0))
chums = self.userlist.findItems(handle, QtCore.Qt.MatchFlag.MatchExactly)
for c in chums:
c.setForeground(QtGui.QBrush(color))
def addMessage(self, text, handle):
@ -1101,10 +1101,10 @@ class PesterMemo(PesterConvo):
msgbox.setText("%s: Invites only!" % (c))
msgbox.setInformativeText("This channel is invite-only. You must get an invitation from someone on the inside before entering.")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.exec_()
msgbox.exec()
def quirkDisable(self, op, msg):
chums = self.userlist.findItems(op, QtCore.Qt.MatchFlags(0))
chums = self.userlist.findItems(op, QtCore.Qt.MatchFlag.MatchExactly)
for c in chums:
if c.op:
if msg == self.mainwindow.profile().handle:
@ -1190,7 +1190,7 @@ class PesterMemo(PesterConvo):
"+a", "-a", "+v", "-v"]) \
and c.lower() != self.channel.lower():
return
chums = self.userlist.findItems(h, QtCore.Qt.MatchFlags(0))
chums = self.userlist.findItems(h, QtCore.Qt.MatchFlag.MatchExactly)
systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"])
# print exit
if update in ("quit", "left", "nick", "netsplit"):
@ -1217,7 +1217,7 @@ class PesterMemo(PesterConvo):
self.mainwindow.chatlog.log(self.channel, msg)
if update == "nick":
self.addUser(newnick)
newchums = self.userlist.findItems(newnick, QtCore.Qt.MatchFlags(0))
newchums = self.userlist.findItems(newnick, QtCore.Qt.MatchFlag.MatchExactly)
for nc in newchums:
for c in chums:
nc.founder = c.founder
@ -1292,7 +1292,7 @@ class PesterMemo(PesterConvo):
# already stealing focus
b.setFocus()
break
ret = msgbox.exec_()
ret = msgbox.exec()
if ret == QtWidgets.QMessageBox.Ok:
self.userlist.clear()
self.time = TimeTracker(curtime)

182
menus.py
View file

@ -1,7 +1,7 @@
import re
from os import remove
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
import ostools
import parsetools
@ -48,32 +48,35 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
self.addItem(item, False)
self.changeCheckState()
#self.setDragEnabled(True)
#self.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
#self.setDragDropMode(QtGui.QAbstractItemView.DragDropMode.InternalMove)
self.setDropIndicatorShown(True)
self.setSortingEnabled(False)
self.setIndentation(15)
self.header().hide()
def addItem(self, item, new=True):
item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsDragEnabled | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable
| QtCore.Qt.ItemFlag.ItemIsDragEnabled
| QtCore.Qt.ItemFlag.ItemIsUserCheckable
| QtCore.Qt.ItemFlag.ItemIsEnabled)
if item.quirk.on:
item.setCheckState(0, 2)
item.setCheckState(0, QtCore.Qt.CheckState.Checked)
else:
item.setCheckState(0, 0)
item.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
if new:
curgroup = self.currentItem()
if curgroup:
if curgroup.parent(): curgroup = curgroup.parent()
item.quirk.quirk["group"] = item.quirk.group = curgroup.text(0)
found = self.findItems(item.quirk.group, QtCore.Qt.MatchExactly)
found = self.findItems(item.quirk.group, QtCore.Qt.MatchFlag.MatchExactly)
if len(found) > 0:
found[0].addChild(item)
else:
child_1 = QtWidgets.QTreeWidgetItem([item.quirk.group])
self.addTopLevelItem(child_1)
child_1.setFlags(child_1.flags() | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
child_1.setChildIndicatorPolicy(QtWidgets.QTreeWidgetItem.DontShowIndicatorWhenChildless)
child_1.setCheckState(0,0)
child_1.setFlags(child_1.flags() | QtCore.Qt.ItemFlag.ItemIsUserCheckable | QtCore.Qt.ItemFlag.ItemIsEnabled)
child_1.setChildIndicatorPolicy(QtWidgets.QTreeWidgetItem.ChildIndicatorPolicy.DontShowIndicatorWhenChildless)
child_1.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
child_1.setExpanded(True)
child_1.addChild(item)
self.changeCheckState()
@ -85,7 +88,7 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
@QtCore.pyqtSlot()
def upShiftQuirk(self):
found = self.findItems(self.currentItem().text(0), QtCore.Qt.MatchExactly)
found = self.findItems(self.currentItem().text(0), QtCore.MatchFlag.Qt.MatchExactly)
if len(found): # group
i = self.indexOfTopLevelItem(found[0])
if i > 0:
@ -95,7 +98,7 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
shifted_item.setExpanded(expand)
self.setCurrentItem(shifted_item)
else: # quirk
found = self.findItems(self.currentItem().text(0), QtCore.Qt.MatchExactly | QtCore.Qt.MatchRecursive)
found = self.findItems(self.currentItem().text(0), QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive)
for f in found:
if not f.isSelected(): continue
if not f.parent(): continue
@ -115,7 +118,7 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
@QtCore.pyqtSlot()
def downShiftQuirk(self):
found = self.findItems(self.currentItem().text(0), QtCore.Qt.MatchExactly)
found = self.findItems(self.currentItem().text(0), QtCore.Qt.MatchFlag.MatchExactly)
if len(found): # group
i = self.indexOfTopLevelItem(found[0])
if i < self.topLevelItemCount()-1 and i >= 0:
@ -125,7 +128,7 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
shifted_item.setExpanded(expand)
self.setCurrentItem(shifted_item)
else: # quirk
found = self.findItems(self.currentItem().text(0), QtCore.Qt.MatchExactly | QtCore.Qt.MatchRecursive)
found = self.findItems(self.currentItem().text(0), QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive)
for f in found:
if not f.isSelected(): continue
if not f.parent(): continue
@ -146,7 +149,7 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
@QtCore.pyqtSlot()
def removeCurrent(self):
i = self.currentItem()
found = self.findItems(i.text(0), QtCore.Qt.MatchExactly | QtCore.Qt.MatchRecursive)
found = self.findItems(i.text(0), QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive)
for f in found:
if not f.isSelected(): continue
if not f.parent(): # group
@ -166,7 +169,7 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
# already stealing focus
b.setFocus()
break
ret = msgbox.exec_()
ret = msgbox.exec()
if ret == QtWidgets.QMessageBox.Ok:
self.takeTopLevelItem(self.indexOfTopLevelItem(f))
else:
@ -185,21 +188,21 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
msgbox = QtWidgets.QMessageBox()
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.exec_()
msgbox.exec()
self.addgroupdialog = None
return
found = self.findItems(gname, QtCore.Qt.MatchExactly)
found = self.findItems(gname, QtCore.Qt.MatchFlag.MatchExactly)
if found:
msgbox = QtWidgets.QMessageBox()
msgbox.setInformativeText("THIS QUIRK GROUP ALREADY EXISTS")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.exec_()
msgbox.exec()
return
child_1 = QtWidgets.QTreeWidgetItem([gname])
self.addTopLevelItem(child_1)
child_1.setFlags(child_1.flags() | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
child_1.setChildIndicatorPolicy(QtWidgets.QTreeWidgetItem.DontShowIndicatorWhenChildless)
child_1.setCheckState(0,0)
child_1.setFlags(child_1.flags() | QtCore.Qt.ItemFlag.ItemIsUserCheckable | QtCore.Qt.ItemFlag.ItemIsEnabled)
child_1.setChildIndicatorPolicy(QtWidgets.QTreeWidgetItem.ChildIndicatorPolicy.DontShowIndicatorWhenChildless)
child_1.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
child_1.setExpanded(True)
self.addgroupdialog = None
@ -216,9 +219,9 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
noneChecked = False
else:
allChecked = False
if allChecked: self.topLevelItem(i).setCheckState(0, 2)
elif noneChecked: self.topLevelItem(i).setCheckState(0, 0)
else: self.topLevelItem(i).setCheckState(0, 1)
if allChecked: self.topLevelItem(i).setCheckState(0, QtCore.Qt.CheckState.Checked)
elif noneChecked: self.topLevelItem(i).setCheckState(0, QtCore.Qt.CheckState.PartiallyChecked)
else: self.topLevelItem(i).setCheckState(0, QtCore.Qt.CheckState.Checked)
else:
state = self.topLevelItem(index).checkState(0)
for j in range(self.topLevelItem(index).childCount()):
@ -293,18 +296,18 @@ class PesterQuirkTypes(QtWidgets.QDialog):
self.cancel = QtWidgets.QPushButton("Cancel", self)
self.cancel.clicked.connect(self.reject)
layout_2 = QtWidgets.QHBoxLayout()
layout_2.setAlignment(QtCore.Qt.AlignRight)
layout_2.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
layout_2.addWidget(self.back)
layout_2.addWidget(self.next)
layout_2.addSpacing(5)
layout_2.addWidget(self.cancel)
vr = QtWidgets.QFrame()
vr.setFrameShape(QtWidgets.QFrame.VLine)
vr.setFrameShadow(QtWidgets.QFrame.Sunken)
vr.setFrameShape(QtWidgets.QFrame.Shape.VLine)
vr.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
vr2 = QtWidgets.QFrame()
vr2.setFrameShape(QtWidgets.QFrame.VLine)
vr2.setFrameShadow(QtWidgets.QFrame.Sunken)
vr2.setFrameShape(QtWidgets.QFrame.Shape.VLine)
vr2.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
self.funclist = QtWidgets.QListWidget(self)
self.funclist.setStyleSheet("color: #000000; background-color: #FFFFFF;")
@ -340,7 +343,7 @@ class PesterQuirkTypes(QtWidgets.QDialog):
widget = QtWidgets.QWidget()
self.pages.addWidget(widget)
layout_select = QtWidgets.QVBoxLayout(widget)
layout_select.setAlignment(QtCore.Qt.AlignTop)
layout_select.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
self.radios = []
self.radios.append(QtWidgets.QRadioButton("Prefix", self))
self.radios.append(QtWidgets.QRadioButton("Suffix", self))
@ -357,7 +360,7 @@ class PesterQuirkTypes(QtWidgets.QDialog):
widget = QtWidgets.QWidget()
self.pages.addWidget(widget)
layout_prefix = QtWidgets.QVBoxLayout(widget)
layout_prefix.setAlignment(QtCore.Qt.AlignTop)
layout_prefix.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_prefix.addWidget(QtWidgets.QLabel("Prefix"))
layout_3 = QtWidgets.QHBoxLayout()
layout_3.addWidget(QtWidgets.QLabel("Value:"))
@ -368,7 +371,7 @@ class PesterQuirkTypes(QtWidgets.QDialog):
widget = QtWidgets.QWidget()
self.pages.addWidget(widget)
layout_suffix = QtWidgets.QVBoxLayout(widget)
layout_suffix.setAlignment(QtCore.Qt.AlignTop)
layout_suffix.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_suffix.addWidget(QtWidgets.QLabel("Suffix"))
layout_3 = QtWidgets.QHBoxLayout()
layout_3.addWidget(QtWidgets.QLabel("Value:"))
@ -379,7 +382,7 @@ class PesterQuirkTypes(QtWidgets.QDialog):
widget = QtWidgets.QWidget()
self.pages.addWidget(widget)
layout_replace = QtWidgets.QVBoxLayout(widget)
layout_replace.setAlignment(QtCore.Qt.AlignTop)
layout_replace.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_replace.addWidget(QtWidgets.QLabel("Simple Replace"))
layout_3 = QtWidgets.QHBoxLayout()
layout_3.addWidget(QtWidgets.QLabel("Replace:"))
@ -401,7 +404,7 @@ class PesterQuirkTypes(QtWidgets.QDialog):
self.pages.addWidget(widget)
layout_all = QtWidgets.QHBoxLayout(widget)
layout_regexp = QtWidgets.QVBoxLayout()
layout_regexp.setAlignment(QtCore.Qt.AlignTop)
layout_regexp.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_regexp.addWidget(QtWidgets.QLabel("Regexp Replace"))
layout_3 = QtWidgets.QHBoxLayout()
layout_3.addWidget(QtWidgets.QLabel("Regexp:"))
@ -427,7 +430,7 @@ class PesterQuirkTypes(QtWidgets.QDialog):
self.pages.addWidget(widget)
layout_all = QtWidgets.QHBoxLayout(widget)
layout_random = QtWidgets.QVBoxLayout()
layout_random.setAlignment(QtCore.Qt.AlignTop)
layout_random.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_random.addWidget(QtWidgets.QLabel("Random Replace"))
layout_5 = QtWidgets.QHBoxLayout()
regexpl = QtWidgets.QLabel("Regexp:", self)
@ -467,14 +470,14 @@ class PesterQuirkTypes(QtWidgets.QDialog):
widget = QtWidgets.QWidget()
self.pages.addWidget(widget)
layout_mispeller = QtWidgets.QVBoxLayout(widget)
layout_mispeller.setAlignment(QtCore.Qt.AlignTop)
layout_mispeller.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_mispeller.addWidget(QtWidgets.QLabel("Mispeller"))
layout_1 = QtWidgets.QHBoxLayout()
zero = QtWidgets.QLabel("1%", self)
hund = QtWidgets.QLabel("100%", self)
self.current = QtWidgets.QLabel("50%", self)
self.current.setAlignment(QtCore.Qt.AlignHCenter)
self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)
self.current.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter)
self.slider = QtWidgets.QSlider(QtCore.Qt.Orientation.Horizontal, self)
self.slider.setMinimum(1)
self.slider.setMaximum(100)
self.slider.setValue(50)
@ -510,14 +513,14 @@ class PesterQuirkTypes(QtWidgets.QDialog):
page.itemAt(1).layout().itemAt(1).widget().setText(q["from"])
page.itemAt(2).layout().itemAt(1).widget().setText(q["to"])
try:
page.itemAt(3).layout().itemAt(0).widget().setCheckState(int(q["checkstate"]))
page.itemAt(3).layout().itemAt(0).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
except (KeyError, ValueError) as e:
print("KeyError: %s" % str(e))
elif q["type"] == "regexp":
page.itemAt(2).layout().itemAt(1).layout().itemAt(1).widget().setText(q["from"])
page.itemAt(2).layout().itemAt(2).layout().itemAt(1).widget().setText(q["to"])
try:
page.itemAt(2).layout().itemAt(3).layout().itemAt(0).widget().setCheckState(int(q["checkstate"]))
page.itemAt(2).layout().itemAt(3).layout().itemAt(0).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
except (KeyError, ValueError) as e:
print("KeyError: %s" % str(e))
elif q["type"] == "random":
@ -525,13 +528,13 @@ class PesterQuirkTypes(QtWidgets.QDialog):
for v in q["randomlist"]:
item = QtWidgets.QListWidgetItem(v, self.replacelist)
try:
page.itemAt(2).layout().itemAt(2).layout().itemAt(0).widget().setCheckState(int(q["checkstate"]))
page.itemAt(2).layout().itemAt(2).layout().itemAt(0).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
except (KeyError, ValueError) as e:
print("KeyError: %s" % str(e))
elif q["type"] == "spelling":
self.slider.setValue(q["percentage"])
try:
page.itemAt(3).layout().itemAt(0).widget().setCheckState(int(q["checkstate"]))
page.itemAt(3).layout().itemAt(0).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
except (KeyError, ValueError) as e:
print("KeyError: %s" % str(e))
@ -673,7 +676,7 @@ class PesterChooseQuirks(QtWidgets.QDialog):
for i in range(self.quirkList.topLevelItemCount()):
for j in range(self.quirkList.topLevelItem(i).childCount()):
item = self.quirkList.topLevelItem(i).child(j)
if (item.checkState(0) == QtCore.Qt.Checked):
if (item.checkState(0) == QtCore.Qt.CheckState.Checked):
u.append(item.quirk)
return u
@ -714,20 +717,20 @@ class PesterChooseQuirks(QtWidgets.QDialog):
elif vdict["type"] == "replace":
vdict["from"] = str(page.itemAt(1).layout().itemAt(1).widget().text())
vdict["to"] = str(page.itemAt(2).layout().itemAt(1).widget().text())
vdict["checkstate"] = str(page.itemAt(3).layout().itemAt(0).widget().checkState())
vdict["checkstate"] = str(page.itemAt(3).layout().itemAt(0).widget().checkState().value)
elif vdict["type"] == "regexp":
vdict["from"] = str(page.itemAt(2).layout().itemAt(1).layout().itemAt(1).widget().text())
vdict["to"] = str(page.itemAt(2).layout().itemAt(2).layout().itemAt(1).widget().text())
vdict["checkstate"] = str(page.itemAt(2).layout().itemAt(3).layout().itemAt(0).widget().checkState())
vdict["checkstate"] = str(page.itemAt(2).layout().itemAt(3).layout().itemAt(0).widget().checkState().value)
elif vdict["type"] == "random":
vdict["from"] = str(self.quirkadd.regexp.text())
vdict["checkstate"] = str(page.itemAt(2).layout().itemAt(2).layout().itemAt(0).widget().checkState())
vdict["checkstate"] = str(page.itemAt(2).layout().itemAt(2).layout().itemAt(0).widget().checkState().value)
randomlist = [str(self.quirkadd.replacelist.item(i).text())
for i in range(0,self.quirkadd.replacelist.count())]
vdict["randomlist"] = randomlist
elif vdict["type"] == "spelling":
vdict["percentage"] = self.quirkadd.slider.value()
vdict["checkstate"] = str(page.itemAt(3).layout().itemAt(0).widget().checkState())
vdict["checkstate"] = str(page.itemAt(3).layout().itemAt(0).widget().checkState().value)
if vdict["type"] in ("regexp", "random"):
try:
re.compile(vdict["from"])
@ -735,7 +738,7 @@ class PesterChooseQuirks(QtWidgets.QDialog):
quirkWarning = QtWidgets.QMessageBox(self)
quirkWarning.setText("Not a valid regular expression!")
quirkWarning.setInformativeText("H3R3S WHY DUMP4SS: %s" % (e))
quirkWarning.exec_()
quirkWarning.exec()
self.quirkadd = None
return
@ -846,7 +849,7 @@ class PesterChooseProfile(QtWidgets.QDialog):
collision_warning = QtWidgets.QLabel("%s is taken already! Pick a new profile." % (collision))
layout_0.addWidget(collision_warning)
else:
layout_0.addWidget(self.currentHandle, alignment=QtCore.Qt.AlignHCenter)
layout_0.addWidget(self.currentHandle, alignment=QtCore.Qt.AlignmentFlag.AlignHCenter)
layout_0.addLayout(layout_1)
if avail_profiles:
profileLabel = QtWidgets.QLabel("Or choose an existing profile:", self)
@ -897,7 +900,7 @@ class PesterChooseProfile(QtWidgets.QDialog):
problem.setWindowTitle("Problem!")
problem.setInformativeText("You can't delete the profile you're currently using!")
problem.setStandardButtons(QtWidgets.QMessageBox.Ok)
problem.exec_()
problem.exec()
return
# TODO: Make this select 'no' as the default, as usual.
msgbox = QtWidgets.QMessageBox()
@ -905,7 +908,7 @@ class PesterChooseProfile(QtWidgets.QDialog):
msgbox.setWindowTitle("WARNING!")
msgbox.setInformativeText("Are you sure you want to delete the profile: %s" % (handle))
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
ret = msgbox.exec_()
ret = msgbox.exec()
if ret == QtWidgets.QMessageBox.Ok:
try:
remove(_datadir+"profiles/%s.js" % (handle))
@ -916,7 +919,7 @@ class PesterChooseProfile(QtWidgets.QDialog):
problem.setWindowTitle("Problem!")
problem.setInformativeText("There was a problem deleting the profile: %s" % (handle))
problem.setStandardButtons(QtWidgets.QMessageBox.Ok)
problem.exec_()
problem.exec()
class PesterMentions(QtWidgets.QDialog):
def __init__(self, window, theme, parent):
@ -979,7 +982,7 @@ class PesterMentions(QtWidgets.QDialog):
quirkWarning = QtWidgets.QMessageBox(self)
quirkWarning.setText("Not a valid regular expression!")
quirkWarning.setInformativeText("H3R3S WHY DUMP4SS: %s" % (e))
quirkWarning.exec_()
quirkWarning.exec()
else:
if mitem is None:
self.mentionlist.addItem(pdict["value"])
@ -1004,17 +1007,17 @@ class PesterOptions(QtWidgets.QDialog):
layout_4 = QtWidgets.QVBoxLayout()
hr = QtWidgets.QFrame()
hr.setFrameShape(QtWidgets.QFrame.HLine)
hr.setFrameShadow(QtWidgets.QFrame.Sunken)
hr.setFrameShape(QtWidgets.QFrame.Shape.HLine)
hr.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
vr = QtWidgets.QFrame()
vr.setFrameShape(QtWidgets.QFrame.VLine)
vr.setFrameShadow(QtWidgets.QFrame.Sunken)
vr.setFrameShape(QtWidgets.QFrame.Shape.VLine)
vr.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
self.tabs = QtWidgets.QButtonGroup(self)
self.tabs.buttonClicked[int].connect(self.changePage)
tabNames = ["Chum List", "Conversations", "Interface", "Sound", "Notifications", "Logging", "Idle/Updates", "Theme", "Connection"]
if parent.advanced: tabNames.append("Advanced")
for t in tabNames:
self.tabs.buttonClicked.connect(self.changePage) # Verify working
self.tabNames = ["Chum List", "Conversations", "Interface", "Sound", "Notifications", "Logging", "Idle/Updates", "Theme", "Connection"]
if parent.advanced: self.tabNames.append("Advanced")
for t in self.tabNames:
button = QtWidgets.QPushButton(t)
self.tabs.addButton(button)
layout_4.addWidget(button)
@ -1036,7 +1039,7 @@ class PesterOptions(QtWidgets.QDialog):
self.autonickserv.stateChanged[int].connect(self.autoNickServChange)
self.nickservpass = QtWidgets.QLineEdit(self)
self.nickservpass.setPlaceholderText("NickServ Password")
self.nickservpass.setEchoMode(QtWidgets.QLineEdit.PasswordEchoOnEdit)
self.nickservpass.setEchoMode(QtWidgets.QLineEdit.EchoMode.PasswordEchoOnEdit)
self.nickservpass.setText(parent.userprofile.getNickServPass())
self.autojoinlist = QtWidgets.QListWidget(self)
@ -1081,7 +1084,7 @@ class PesterOptions(QtWidgets.QDialog):
self.editMentions2 = QtWidgets.QPushButton("Edit Mentions", self)
self.editMentions2.clicked.connect(self.openMentions)
self.volume = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)
self.volume = QtWidgets.QSlider(QtCore.Qt.Orientation.Horizontal, self)
self.volume.setMinimum(0)
self.volume.setMaximum(100)
self.volume.setValue(self.config.volume())
@ -1098,7 +1101,7 @@ class PesterOptions(QtWidgets.QDialog):
self.currentVol = QtWidgets.QLabel(
"(Disabled: Sound Mixer Error)", self)
self.volume.setEnabled(False)
self.currentVol.setAlignment(QtCore.Qt.AlignHCenter)
self.currentVol.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter)
self.timestampcheck = QtWidgets.QCheckBox("Time Stamps", self)
@ -1282,7 +1285,7 @@ class PesterOptions(QtWidgets.QDialog):
# Chum List
widget = QtWidgets.QWidget()
layout_chumlist = QtWidgets.QVBoxLayout(widget)
layout_chumlist.setAlignment(QtCore.Qt.AlignTop)
layout_chumlist.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_chumlist.addWidget(self.hideOffline)
#layout_chumlist.addWidget(self.groupscheck)
layout_chumlist.addWidget(self.showemptycheck)
@ -1293,7 +1296,7 @@ class PesterOptions(QtWidgets.QDialog):
# Conversations
widget = QtWidgets.QWidget()
layout_chat = QtWidgets.QVBoxLayout(widget)
layout_chat.setAlignment(QtCore.Qt.AlignTop)
layout_chat.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_chat.addWidget(self.timestampcheck)
layout_chat.addWidget(self.timestampBox)
layout_chat.addWidget(self.secondscheck)
@ -1311,7 +1314,7 @@ class PesterOptions(QtWidgets.QDialog):
# Interface
widget = QtWidgets.QWidget()
layout_interface = QtWidgets.QVBoxLayout(widget)
layout_interface.setAlignment(QtCore.Qt.AlignTop)
layout_interface.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_interface.addWidget(self.tabcheck)
layout_interface.addWidget(self.tabmemocheck)
layout_interface.addLayout(layout_mini)
@ -1323,7 +1326,7 @@ class PesterOptions(QtWidgets.QDialog):
# Sound
widget = QtWidgets.QWidget()
layout_sound = QtWidgets.QVBoxLayout(widget)
layout_sound.setAlignment(QtCore.Qt.AlignTop)
layout_sound.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_sound.addWidget(self.soundcheck)
layout_indent = QtWidgets.QVBoxLayout()
layout_indent.addWidget(self.chatsoundcheck)
@ -1351,7 +1354,7 @@ class PesterOptions(QtWidgets.QDialog):
# Notifications
widget = QtWidgets.QWidget()
layout_notify = QtWidgets.QVBoxLayout(widget)
layout_notify.setAlignment(QtCore.Qt.AlignTop)
layout_notify.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_notify.addWidget(self.notifycheck)
layout_indent = QtWidgets.QVBoxLayout()
layout_indent.addLayout(layout_type)
@ -1371,7 +1374,7 @@ class PesterOptions(QtWidgets.QDialog):
# Logging
widget = QtWidgets.QWidget()
layout_logs = QtWidgets.QVBoxLayout(widget)
layout_logs.setAlignment(QtCore.Qt.AlignTop)
layout_logs.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_logs.addWidget(self.logpesterscheck)
layout_logs.addWidget(self.logmemoscheck)
layout_logs.addWidget(self.stamppestercheck)
@ -1381,7 +1384,7 @@ class PesterOptions(QtWidgets.QDialog):
# Idle/Updates
widget = QtWidgets.QWidget()
layout_idle = QtWidgets.QVBoxLayout(widget)
layout_idle.setAlignment(QtCore.Qt.AlignTop)
layout_idle.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_idle.addLayout(layout_5)
layout_idle.addLayout(layout_6)
#if not ostools.isOSXLeopard():
@ -1391,7 +1394,7 @@ class PesterOptions(QtWidgets.QDialog):
# Theme
widget = QtWidgets.QWidget()
layout_theme = QtWidgets.QVBoxLayout(widget)
layout_theme.setAlignment(QtCore.Qt.AlignTop)
layout_theme.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_theme.addWidget(QtWidgets.QLabel("Pick a Theme:"))
layout_theme.addWidget(self.themeBox)
layout_theme.addWidget(self.refreshtheme)
@ -1401,7 +1404,7 @@ class PesterOptions(QtWidgets.QDialog):
# Connection
widget = QtWidgets.QWidget()
layout_connect = QtWidgets.QVBoxLayout(widget)
layout_connect.setAlignment(QtCore.Qt.AlignTop)
layout_connect.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_connect.addWidget(self.bandwidthcheck)
layout_connect.addWidget(bandwidthLabel)
layout_connect.addWidget(self.autonickserv)
@ -1421,7 +1424,7 @@ class PesterOptions(QtWidgets.QDialog):
if parent.advanced:
widget = QtWidgets.QWidget()
layout_advanced = QtWidgets.QVBoxLayout(widget)
layout_advanced.setAlignment(QtCore.Qt.AlignTop)
layout_advanced.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_advanced.addWidget(QtWidgets.QLabel("Current User Mode: %s" % parent.modes))
layout_advanced.addLayout(layout_change)
self.pages.addWidget(widget)
@ -1437,12 +1440,9 @@ class PesterOptions(QtWidgets.QDialog):
self.setLayout(layout_0)
@QtCore.pyqtSlot(int)
def changePage(self, page):
self.tabs.button(page).setChecked(True)
# What is this, I don't even. qt, fuck
page = -page - 2
self.pages.setCurrentIndex(page)
@QtCore.pyqtSlot(QtWidgets.QAbstractButton)
def changePage(self, button):
self.pages.setCurrentIndex(self.tabNames.index(button.text()))
@QtCore.pyqtSlot(int)
def notifyChange(self, state):
@ -1477,7 +1477,7 @@ class PesterOptions(QtWidgets.QDialog):
return
pdict["value"] = "#" + pdict["value"]
if mitem is None:
items = self.autojoinlist.findItems(pdict["value"], QtCore.Qt.MatchFixedString)
items = self.autojoinlist.findItems(pdict["value"], QtCore.Qt.MatchFlag.MatchFixedString)
if len(items) == 0:
self.autojoinlist.addItem(pdict["value"])
else:
@ -1555,9 +1555,9 @@ class PesterUserlist(QtWidgets.QDialog):
self.userarea.setStyleSheet(self.theme["main/chums/style"])
self.userarea.optionsMenu = QtWidgets.QMenu(self)
self.addChumAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
self.addChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
self.addChumAction.triggered.connect(self.addChumSlot)
self.pesterChumAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self)
self.pesterChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self)
self.pesterChumAction.triggered.connect(self.pesterChumSlot)
self.userarea.optionsMenu.addAction(self.addChumAction)
self.userarea.optionsMenu.addAction(self.pesterChumAction)
@ -1586,6 +1586,8 @@ class PesterUserlist(QtWidgets.QDialog):
self.userarea.clear()
for n in names:
if str(self.searchbox.text()) == "" or n.lower().find(str(self.searchbox.text()).lower()) != -1:
# Strip channel membership prefixes
n = n.strip('~').strip('@').strip('+').strip('&').strip('%')
item = QtWidgets.QListWidgetItem(n)
item.setForeground(QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"])))
self.userarea.addItem(item)
@ -1607,7 +1609,7 @@ class PesterUserlist(QtWidgets.QDialog):
self.userarea.addItem(item)
self.userarea.sortItems()
def delUser(self, name):
matches = self.userarea.findItems(name, QtCore.Qt.MatchFlags(0))
matches = self.userarea.findItems(name, QtCore.Qt.MatchFlag.MatchExactly)
for m in matches:
self.userarea.takeItem(self.userarea.row(m))
@ -1657,7 +1659,7 @@ class PesterMemoList(QtWidgets.QDialog):
self.label = QtWidgets.QLabel("MEMOS")
self.channelarea = RightClickTree(self)
self.channelarea.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
self.channelarea.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection)
self.channelarea.setStyleSheet(self.theme["main/chums/style"])
self.channelarea.optionsMenu = QtWidgets.QMenu(self)
self.channelarea.setColumnCount(2)
@ -1666,7 +1668,7 @@ class PesterMemoList(QtWidgets.QDialog):
self.channelarea.setColumnWidth(0,200)
self.channelarea.setColumnWidth(1,10)
self.channelarea.setSortingEnabled(True)
self.channelarea.sortByColumn(0, QtCore.Qt.AscendingOrder)
self.channelarea.sortByColumn(0, QtCore.Qt.SortOrder.AscendingOrder)
self.channelarea.itemDoubleClicked[QtWidgets.QTreeWidgetItem, int].connect(self.AcceptSelection)
self.orjoinlabel = QtWidgets.QLabel("OR MAKE A NEW MEMO:")
@ -1675,7 +1677,7 @@ class PesterMemoList(QtWidgets.QDialog):
self.inviteChannel = QtWidgets.QCheckBox("INVITATION ONLY?", self)
self.timelabel = QtWidgets.QLabel("TIMEFRAME:")
self.timeslider = TimeSlider(QtCore.Qt.Horizontal, self)
self.timeslider = TimeSlider(QtCore.Qt.Orientation.Horizontal, self)
self.timeinput = TimeInput(self.timeslider, self)
self.cancel = QtWidgets.QPushButton("CANCEL", self)
@ -1689,7 +1691,7 @@ class PesterMemoList(QtWidgets.QDialog):
layout_left = QtWidgets.QVBoxLayout()
layout_right = QtWidgets.QVBoxLayout()
layout_right.setAlignment(QtCore.Qt.AlignTop)
layout_right.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
layout_0 = QtWidgets.QVBoxLayout()
layout_1 = QtWidgets.QHBoxLayout()
layout_left.addWidget(self.label)
@ -1746,8 +1748,8 @@ class LoadingScreen(QtWidgets.QDialog):
tryAgain = QtCore.pyqtSignal()
def __init__(self, parent=None):
QtWidgets.QDialog.__init__(self, parent, (QtCore.Qt.CustomizeWindowHint |
QtCore.Qt.FramelessWindowHint))
QtWidgets.QDialog.__init__(self, parent, (QtCore.Qt.WindowType.CustomizeWindowHint |
QtCore.Qt.WindowType.FramelessWindowHint))
self.mainwindow = parent
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])

View file

@ -1,4 +1,4 @@
from PyQt5 import QtCore, QtWidgets
from PyQt6 import QtCore, QtWidgets
from generic import PesterIcon

View file

@ -2,7 +2,7 @@ import os
import sys
import platform
from PyQt5.QtCore import QStandardPaths
from PyQt6.QtCore import QStandardPaths
def isOSX():
return sys.platform == "darwin"
@ -34,10 +34,10 @@ def getDataDir():
# in the Pesterchum install directory (like before)
try:
if isOSX():
return os.path.join(str(QStandardPaths.writableLocation(QStandardPaths.DataLocation)), "Pesterchum/")
return os.path.join(QStandardPaths.writableLocation(QStandardPaths.StandardLocation.DataLocation), "Pesterchum/")
elif isLinux():
return os.path.join(str(QStandardPaths.writableLocation(QStandardPaths.HomeLocation)), ".pesterchum/")
return os.path.join(QStandardPaths.writableLocation(QStandardPaths.StandardLocation.HomeLocation), ".pesterchum/")
else:
return os.path.join(str(QStandardPaths.writableLocation(QStandardPaths.DataLocation)), "pesterchum/")
return os.path.join(QStandardPaths.writableLocation(QStandardPaths.StandardLocation.DataLocation), "pesterchum/")
except UnicodeDecodeError:
return ''

View file

@ -5,7 +5,7 @@ import collections
from copy import copy
from datetime import timedelta
from PyQt5 import QtGui, QtWidgets
from PyQt6 import QtGui, QtWidgets
import dataobjs
import ostools
@ -701,7 +701,7 @@ def kxhandleInput(ctx, text=None, flavor=None):
err_info = "A quirk seems to be having a problem. (Error: {!s})"
err_info = err_info.format(err)
msgbox.setInformativeText(err_info)
msgbox.exec_()
msgbox.exec()
return
# Debug output.

View file

@ -41,7 +41,7 @@ from pnc.dep.attrdict import AttrDict
reqmissing = []
optmissing = []
try:
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
except ImportError as e:
module = str(e)
if module.startswith("No module named ") or \
@ -393,23 +393,23 @@ class chumArea(RightClickTree):
self.groupMenu = QtWidgets.QMenu(self)
self.canonMenu = QtWidgets.QMenu(self)
self.optionsMenu = QtWidgets.QMenu(self)
self.pester = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self)
self.pester = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self)
self.pester.triggered.connect(self.activateChum)
self.removechum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/removechum"], self)
self.removechum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/removechum"], self)
self.removechum.triggered.connect(self.removeChum)
self.blockchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self)
self.blockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self)
self.blockchum.triggered.connect(self.blockChum)
self.logchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self)
self.logchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self)
self.logchum.triggered.connect(self.openChumLogs)
self.reportchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self)
self.reportchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self)
self.reportchum.triggered.connect(self.reportChum)
self.findalts = QtWidgets.QAction("Find Alts", self)
self.findalts = QtGui.QAction("Find Alts", self)
self.findalts.triggered.connect(self.findAlts)
self.removegroup = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/removegroup"], self)
self.removegroup = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/removegroup"], self)
self.removegroup.triggered.connect(self.removeGroup)
self.renamegroup = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/renamegroup"], self)
self.renamegroup = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/renamegroup"], self)
self.renamegroup.triggered.connect(self.renameGroup)
self.notes = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/notes"], self)
self.notes = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/notes"], self)
self.notes.triggered.connect(self.editNotes)
self.optionsMenu.addAction(self.pester)
@ -435,13 +435,13 @@ class chumArea(RightClickTree):
self.initTheme(theme)
#self.sortItems()
#self.sortItems(1, QtCore.Qt.AscendingOrder)
#self.sortItems(1, QtCore.Qt.SortOrder.AscendingOrder)
self.setSortingEnabled(False)
self.header().hide()
self.setDropIndicatorShown(True)
self.setIndentation(4)
self.setDragEnabled(True)
self.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
self.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.InternalMove)
self.setAnimated(True)
self.setRootIsDecorated(False)
@ -482,13 +482,13 @@ class chumArea(RightClickTree):
# start drag
drag = QtGui.QDrag(self)
drag.setMimeData(mime)
drag.exec_(QtCore.Qt.MoveAction)
drag.exec(QtCore.Qt.DropAction.MoveAction)
except:
logging.exception('')
def dragMoveEvent(self, event):
if event.mimeData().hasFormat("application/x-item"):
event.setDropAction(QtCore.Qt.MoveAction)
event.setDropAction(QtCore.Qt.DropAction.MoveAction)
event.accept()
else:
event.ignore()
@ -587,7 +587,7 @@ class chumArea(RightClickTree):
text = text[0:text.rfind(" (")]
currentGroup = text
self.moveMenu.clear()
actGroup = QtWidgets.QActionGroup(self)
actGroup = QtGui.QActionGroup(self)
groups = self.groups[:]
for gtext in groups:
@ -595,7 +595,7 @@ class chumArea(RightClickTree):
continue
movegroup = self.moveMenu.addAction(gtext)
actGroup.addAction(movegroup)
actGroup.triggered[QtWidgets.QAction].connect(self.moveToGroup)
actGroup.triggered[QtGui.QAction].connect(self.moveToGroup)
def addChum(self, chum):
if len([c for c in self.chums if c.handle == chum.handle]) != 0:
@ -606,16 +606,16 @@ class chumArea(RightClickTree):
chumLabel = chumListing(chum, self.mainwindow)
self.addItem(chumLabel)
#self.topLevelItem(0).addChild(chumLabel)
#self.topLevelItem(0).sortChildren(0, QtCore.Qt.AscendingOrder)
#self.topLevelItem(0).sortChildren(0, QtCore.Qt.SortOrder.AscendingOrder)
def getChums(self, handle):
chums = self.findItems(handle, QtCore.Qt.MatchExactly | QtCore.Qt.MatchRecursive)
chums = self.findItems(handle, QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive)
return chums
def showAllChums(self):
for c in self.chums:
chandle = c.handle
if not len(self.findItems(chandle, QtCore.Qt.MatchExactly | QtCore.Qt.MatchRecursive)):
if not len(self.findItems(chandle, QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive)):
#if True:# For if it doesn't work at all :/
chumLabel = chumListing(c, self.mainwindow)
self.addItem(chumLabel)
@ -724,7 +724,7 @@ class chumArea(RightClickTree):
if text.rfind(" (") != -1:
text = text[0:text.rfind(" (")]
curgroups.append(text)
if not self.findItems(chumLabel.handle, QtCore.Qt.MatchExactly | QtCore.Qt.MatchRecursive):
if not self.findItems(chumLabel.handle, QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive):
#if True:# For if it doesn't work at all :/
if chumLabel.chum.group not in curgroups:
child_1 = QtWidgets.QTreeWidgetItem(["%s" % (chumLabel.chum.group)])
@ -777,10 +777,10 @@ class chumArea(RightClickTree):
if self.mainwindow.config.showOnlineNumbers():
self.showOnlineNumbers()
else: # usually means this is now the trollslum
if not self.findItems(chumLabel.handle, QtCore.Qt.MatchExactly | QtCore.Qt.MatchRecursive):
if not self.findItems(chumLabel.handle, QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive):
#if True:# For if it doesn't work at all :/
self.topLevelItem(0).addChild(chumLabel)
self.topLevelItem(0).sortChildren(0, QtCore.Qt.AscendingOrder)
self.topLevelItem(0).sortChildren(0, QtCore.Qt.SortOrder.AscendingOrder)
def takeItem(self, chumLabel):
r = None
if not hasattr(chumLabel, 'chum'):
@ -827,7 +827,7 @@ class chumArea(RightClickTree):
self.showOnlineNumbers()
return oldmood
def updateColor(self, handle, color):
chums = self.findItems(handle, QtCore.Qt.MatchFlags(0))
chums = self.findItems(handle, QtCore.Qt.MatchFlag.MatchExactly)
for c in chums:
c.setColor(color)
def initTheme(self, theme):
@ -883,7 +883,7 @@ class chumArea(RightClickTree):
self.moodSort(i)
else:
for i in range(self.topLevelItemCount()):
self.topLevelItem(i).sortChildren(0, QtCore.Qt.AscendingOrder)
self.topLevelItem(i).sortChildren(0, QtCore.Qt.SortOrder.AscendingOrder)
def moodSort(self, group):
scrollPos = self.verticalScrollBar().sliderPosition()
chums = []
@ -969,7 +969,7 @@ class chumArea(RightClickTree):
msgbox.setStyleSheet("QMessageBox{" + self.mainwindow.theme["main/defaultwindow/style"] + "}")
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.exec_()
msgbox.exec()
self.addgroupdialog = None
return
currentGroup = self.currentItem()
@ -1017,7 +1017,7 @@ class chumArea(RightClickTree):
self.takeItem(chumLabel)
self.addItem(chumLabel)
self.takeTopLevelItem(i)
@QtCore.pyqtSlot(QtWidgets.QAction)
@QtCore.pyqtSlot(QtGui.QAction)
def moveToGroup(self, item):
if not item:
return
@ -1049,7 +1049,7 @@ class trollSlum(chumArea):
child_1.setExpanded(True)
for c in self.chums:
chandle = c.handle
if not self.findItems(chandle, QtCore.Qt.MatchFlags(0)):
if not self.findItems(chandle, QtCore.Qt.MatchFlag.MatchExactly):
chumLabel = chumListing(c, self.mainwindow)
self.addItem(chumLabel)
@ -1059,14 +1059,14 @@ class trollSlum(chumArea):
self.setIndentation(0)
self.optionsMenu = QtWidgets.QMenu(self)
self.unblockchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self)
self.unblockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self)
self.unblockchum.triggered.connect(self.unblockChumSignal)
self.optionsMenu.addAction(self.unblockchum)
#self.sortItems()
def contextMenuEvent(self, event):
#fuckin Qt
if event.reason() == QtGui.QContextMenuEvent.Mouse:
if event.reason() == QtGui.QContextMenuEvent.Reason.Mouse:
listing = self.itemAt(event.pos())
self.setCurrentItem(listing)
if self.currentItem().text(0) != "":
@ -1166,8 +1166,8 @@ class PesterWindow(MovingWindow):
def __init__(self, options, parent=None, app=None):
super(PesterWindow, self).__init__(None,
(QtCore.Qt.CustomizeWindowHint |
QtCore.Qt.FramelessWindowHint))
(QtCore.Qt.WindowType.CustomizeWindowHint |
QtCore.Qt.WindowType.FramelessWindowHint))
# For debugging
_CONSOLE_ENV.PAPP = self
@ -1210,7 +1210,7 @@ class PesterWindow(MovingWindow):
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Information)
msgBox.setWindowTitle(":(")
msgBox.setTextFormat(QtCore.Qt.RichText) # Clickable html links
msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links
self.filename = _datadir+"pesterchum.js"
msgBox.setText("<html><h3>A profile error occured, trying to switch to default pesterClient profile." + \
"<br><br>" + str(e) + "<\h3><\html>")
@ -1218,7 +1218,7 @@ class PesterWindow(MovingWindow):
#_datadir+"pesterchum.js" + \
#"\"")
PchumLog.critical(e)
msgBox.exec_()
msgBox.exec()
self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0)))
self.theme = self.userprofile.getTheme()
@ -1252,7 +1252,7 @@ class PesterWindow(MovingWindow):
PchumLog.error("Caught: " + inst.parameter)
themeWarning = QtWidgets.QMessageBox(self)
themeWarning.setText("Theme Error: %s" % inst)
themeWarning.exec_()
themeWarning.exec()
self.theme = pesterTheme("pesterchum")
extraToasts = {'default': PesterToast}
@ -1266,35 +1266,35 @@ class PesterWindow(MovingWindow):
self.move(100, 100)
talk = QtWidgets.QAction(self.theme["main/menus/client/talk"], self)
talk = QtGui.QAction(self.theme["main/menus/client/talk"], self)
self.talk = talk
talk.triggered.connect(self.openChat)
logv = QtWidgets.QAction(self.theme["main/menus/client/logviewer"], self)
logv = QtGui.QAction(self.theme["main/menus/client/logviewer"], self)
self.logv = logv
logv.triggered.connect(self.openLogv)
grps = QtWidgets.QAction(self.theme["main/menus/client/addgroup"], self)
grps = QtGui.QAction(self.theme["main/menus/client/addgroup"], self)
self.grps = grps
grps.triggered.connect(self.addGroupWindow)
self.rand = QtWidgets.QAction(self.theme["main/menus/client/randen"], self)
self.rand = QtGui.QAction(self.theme["main/menus/client/randen"], self)
self.rand.triggered.connect(self.randhandler.getEncounter)
opts = QtWidgets.QAction(self.theme["main/menus/client/options"], self)
opts = QtGui.QAction(self.theme["main/menus/client/options"], self)
self.opts = opts
opts.triggered.connect(self.openOpts)
exitaction = QtWidgets.QAction(self.theme["main/menus/client/exit"], self)
exitaction = QtGui.QAction(self.theme["main/menus/client/exit"], self)
self.exitaction = exitaction
exitaction.triggered.connect(self.quit)
userlistaction = QtWidgets.QAction(self.theme["main/menus/client/userlist"], self)
userlistaction = QtGui.QAction(self.theme["main/menus/client/userlist"], self)
self.userlistaction = userlistaction
userlistaction.triggered.connect(self.showAllUsers)
memoaction = QtWidgets.QAction(self.theme["main/menus/client/memos"], self)
memoaction = QtGui.QAction(self.theme["main/menus/client/memos"], self)
self.memoaction = memoaction
memoaction.triggered.connect(self.showMemos)
self.importaction = QtWidgets.QAction(self.theme["main/menus/client/import"], self)
self.importaction = QtGui.QAction(self.theme["main/menus/client/import"], self)
self.importaction.triggered.connect(self.importExternalConfig)
self.idleaction = QtWidgets.QAction(self.theme["main/menus/client/idle"], self)
self.idleaction = QtGui.QAction(self.theme["main/menus/client/idle"], self)
self.idleaction.setCheckable(True)
self.idleaction.toggled[bool].connect(self.toggleIdle)
self.reconnectAction = QtWidgets.QAction(self.theme["main/menus/client/reconnect"], self)
self.reconnectAction = QtGui.QAction(self.theme["main/menus/client/reconnect"], self)
self.reconnectAction.triggered.connect(self.reconnectIRC)
self.menu = QtWidgets.QMenuBar(self)
@ -1304,25 +1304,25 @@ class PesterWindow(MovingWindow):
if self.theme.has_key("main/menus/client/console"):
self.console = AttrDict(dict(
window = None,
action = QtWidgets.QAction(self.theme["main/menus/client/console"], self),
action = QtGui.QAction(self.theme["main/menus/client/console"], self),
is_open = False
))
else:
self.console = AttrDict(dict(
window = None,
action = QtWidgets.QAction("Console", self),
action = QtGui.QAction("Console", self),
is_open = False
))
self.console.shortcuts = AttrDict(dict(
conkey = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+`"), self,
context=QtCore.Qt.ApplicationShortcut),
curwgt = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+Alt+w"), self,
context=QtCore.Qt.ApplicationShortcut)
conkey = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+`"), self,
context=QtCore.Qt.ShortcutContext.ApplicationShortcut),
curwgt = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+Alt+w"), self,
context=QtCore.Qt.ShortcutContext.ApplicationShortcut)
))
self.console.action.triggered.connect(self.toggleConsole)
# Make sure the shortcut works anywhere.
# karxi: There's something wrong with the inheritance scheme here.
#~self.console.shortcuts.conkey.setContext(QtCore.Qt.ApplicationShortcut)
#~self.console.shortcuts.conkey.setContext(QtCore.Qt.ShortcutContext.ApplicationShortcut)
self.console.shortcuts.conkey.activated.connect(self.toggleConsole)
#~# Use new-style connections
#~self.console.shortcut.activated.connect(self.toggleConsole)
@ -1349,18 +1349,18 @@ class PesterWindow(MovingWindow):
filemenu.addAction(self.reconnectAction)
filemenu.addAction(exitaction)
changequirks = QtWidgets.QAction(self.theme["main/menus/profile/quirks"], self)
changequirks = QtGui.QAction(self.theme["main/menus/profile/quirks"], self)
self.changequirks = changequirks
changequirks.triggered.connect(self.openQuirks)
loadslum = QtWidgets.QAction(self.theme["main/menus/profile/block"], self)
loadslum = QtGui.QAction(self.theme["main/menus/profile/block"], self)
self.loadslum = loadslum
loadslum.triggered.connect(self.showTrollSlum)
changecoloraction = QtWidgets.QAction(self.theme["main/menus/profile/color"], self)
changecoloraction = QtGui.QAction(self.theme["main/menus/profile/color"], self)
self.changecoloraction = changecoloraction
changecoloraction.triggered.connect(self.changeMyColor)
switch = QtWidgets.QAction(self.theme["main/menus/profile/switch"], self)
switch = QtGui.QAction(self.theme["main/menus/profile/switch"], self)
self.switch = switch
switch.triggered.connect(self.switchProfile)
@ -1371,27 +1371,27 @@ class PesterWindow(MovingWindow):
profilemenu.addAction(changecoloraction)
profilemenu.addAction(switch)
self.helpAction = QtWidgets.QAction(self.theme["main/menus/help/help"], self)
self.helpAction = QtGui.QAction(self.theme["main/menus/help/help"], self)
self.helpAction.triggered.connect(self.launchHelp)
self.botAction = QtWidgets.QAction(self.theme["main/menus/help/calsprite"], self)
self.botAction = QtGui.QAction(self.theme["main/menus/help/calsprite"], self)
self.botAction.triggered.connect(self.loadCalsprite)
self.nickServAction = QtWidgets.QAction(self.theme["main/menus/help/nickserv"], self)
self.nickServAction = QtGui.QAction(self.theme["main/menus/help/nickserv"], self)
self.nickServAction.triggered.connect(self.loadNickServ)
self.chanServAction = QtWidgets.QAction(self.theme["main/menus/help/chanserv"], self)
self.chanServAction = QtGui.QAction(self.theme["main/menus/help/chanserv"], self)
self.chanServAction.triggered.connect(self.loadChanServ)
self.aboutAction = QtWidgets.QAction(self.theme["main/menus/help/about"], self)
self.aboutAction = QtGui.QAction(self.theme["main/menus/help/about"], self)
self.aboutAction.triggered.connect(self.aboutPesterchum)
# Because I can't expect all themes to have this included.
#if self.theme.has_key("main/menus/help/reportbug"):
try:
self.reportBugAction = QtWidgets.QAction(self.theme["main/menus/help/reportbug"], self)
self.reportBugAction = QtGui.QAction(self.theme["main/menus/help/reportbug"], self)
except:
self.reportBugAction = QtWidgets.QAction("REPORT BUG", self)
self.reportBugAction = QtGui.QAction("REPORT BUG", self)
try:
self.xyzRulesAction = QtWidgets.QAction(self.theme["main/menus/help/rules"], self)
self.xyzRulesAction = QtGui.QAction(self.theme["main/menus/help/rules"], self)
except:
self.xyzRulesAction = QtWidgets.QAction("RULES", self)
self.xyzRulesAction = QtGui.QAction("RULES", self)
self.reportBugAction.triggered.connect(self.reportBug)
self.xyzRulesAction.triggered.connect(self.xyzRules)
@ -1561,7 +1561,7 @@ class PesterWindow(MovingWindow):
else:
palette = QtGui.QPalette()
brush = QtGui.QBrush(self.backgroundImage)
palette.setBrush(QtGui.QPalette.Window, brush)
palette.setBrush(QtGui.QPalette.ColorRole.Window, brush)
self.setPalette(palette)
@QtCore.pyqtSlot()
@ -1857,28 +1857,22 @@ class PesterWindow(MovingWindow):
self.chooseprofile = None
if not self.chooseprofile:
self.chooseprofile = PesterChooseProfile(self.userprofile, self.config, self.theme, self, collision=collision)
self.chooseprofile.exec_()
self.chooseprofile.exec()
def themePicker(self):
if not hasattr(self, 'choosetheme'):
self.choosetheme = None
if not self.choosetheme:
self.choosetheme = PesterChooseTheme(self.config, self.theme, self)
self.choosetheme.exec_()
self.choosetheme.exec()
def initTheme(self, theme):
self.resize(*theme["main/size"])
self.setWindowIcon(PesterIcon(theme["main/icon"]))
self.setWindowTitle(theme["main/windowtitle"])
self.setStyleSheet("QtWidgets.QFrame#main { %s }" % (theme["main/style"]))
# QPixmap::mask and setMask are legacy and should probably be replaced;
# https://doc.qt.io/qt-5/qpixmap.html#pixmap-information
# It's slow and this way we don't use antialiasing, leaving us with very ugly borders.
# + It breaks transparency on Wayland: https://bugreports-test.qt.io/browse/QTBUG-69906
self.backgroundImage = QtGui.QImage(theme["main/background-image"])
self.backgroundPixmap = QtGui.QPixmap.fromImage(self.backgroundImage)
self.backgroundMask = self.backgroundPixmap.mask()
self.setMask(self.backgroundMask)
self.backgroundImage = QtGui.QPixmap(theme["main/background-image"])
self.setMask(self.backgroundImage.mask())
self.menu.setStyleSheet("QMenuBar { background: transparent; %s } QMenuBar::item { background: transparent; %s } "
% (theme["main/menubar/style"],
@ -2100,7 +2094,7 @@ class PesterWindow(MovingWindow):
except ThemeException as inst:
themeWarning = QtWidgets.QMessageBox(self)
themeWarning.setText("Theme Error: %s" % inst)
themeWarning.exec_()
themeWarning.exec()
theme = pesterTheme("pesterchum")
return
self.theme = theme
@ -2164,7 +2158,7 @@ class PesterWindow(MovingWindow):
@QtCore.pyqtSlot()
def connected(self):
if self.loadingscreen:
self.loadingscreen.done(QtWidgets.QDialog.Accepted)
self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted)
self.loadingscreen = None
self.doAutoIdentify()
@ -2259,7 +2253,7 @@ class PesterWindow(MovingWindow):
msgbox.setText("This chumhandle has been registered; you may not use it.")
msgbox.setInformativeText("Your handle is now being changed to %s." % (changedto))
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.exec_()
msgbox.exec()
elif h == self.randhandler.randNick:
self.randhandler.incoming(msg)
elif h in self.convos:
@ -2286,7 +2280,7 @@ class PesterWindow(MovingWindow):
# already stealing focus
b.setFocus()
break
ret = msgbox.exec_()
ret = msgbox.exec()
if ret == QtWidgets.QMessageBox.Ok:
self.newMemo(str(channel), "+0:00")
@QtCore.pyqtSlot(QString)
@ -2374,7 +2368,7 @@ class PesterWindow(MovingWindow):
if not self.addchumdialog:
available_groups = [g[0] for g in self.config.getGroups()]
self.addchumdialog = AddChumDialog(available_groups, self)
ok = self.addchumdialog.exec_()
ok = self.addchumdialog.exec()
handle = str(self.addchumdialog.chumBox.text()).strip()
newgroup = str(self.addchumdialog.newgroup.text()).strip()
selectedGroup = self.addchumdialog.groupBox.currentText()
@ -2655,7 +2649,7 @@ class PesterWindow(MovingWindow):
curgroup = str(self.quirkmenu.quirkList.topLevelItem(i).text(0))
for j in range(self.quirkmenu.quirkList.topLevelItem(i).childCount()):
item = self.quirkmenu.quirkList.topLevelItem(i).child(j)
item.quirk.quirk["on"] = item.quirk.on = (item.checkState(0) == QtCore.Qt.Checked)
item.quirk.quirk["on"] = item.quirk.on = (item.checkState(0) == QtCore.Qt.CheckState.Checked)
item.quirk.quirk["group"] = item.quirk.group = curgroup
quirks = pesterQuirks(self.quirkmenu.quirks())
self.userprofile.setQuirks(quirks)
@ -2709,7 +2703,7 @@ class PesterWindow(MovingWindow):
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}")#Style :) (memos/style or convo/style works :3 )
msgbox.exec_()
msgbox.exec()
self.addgroupdialog = None
return
self.addGroup(gname)
@ -3016,7 +3010,7 @@ class PesterWindow(MovingWindow):
except ValueError as e:
themeWarning = QtWidgets.QMessageBox(self)
themeWarning.setText("Theme Error: %s" % (e))
themeWarning.exec_()
themeWarning.exec()
self.choosetheme = None
return
# update profile
@ -3040,7 +3034,7 @@ class PesterWindow(MovingWindow):
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Warning)
msgBox.setWindowTitle(":(")
msgBox.setTextFormat(QtCore.Qt.RichText) # Clickable html links
msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links
self.filename = _datadir+"pesterchum.js"
try:
msgBox.setText("<html><h3>Failed to load: " + ("<a href='%s'>%s/%s.js</a>" % (self.profiledir, self.profiledir, user)) + \
@ -3058,7 +3052,7 @@ class PesterWindow(MovingWindow):
"<br><br>" + str(e) + "<\h3><\html>")
PchumLog.critical(e)
msgBox.exec_()
msgBox.exec()
return
else:
handle = str(self.chooseprofile.chumHandle.text())
@ -3120,7 +3114,7 @@ class PesterWindow(MovingWindow):
closeWarning.setInformativeText("i warned you about windows bro!!!! i told you dog!")
closeWarning.setStandardButtons(QtWidgets.QMessageBox.Cancel | QtWidgets.QMessageBox.Ok)
closeWarning.setDefaultButton(QtWidgets.QMessageBox.Ok)
ret = closeWarning.exec_()
ret = closeWarning.exec()
if ret == QtWidgets.QMessageBox.Cancel:
return
self.changeProfile()
@ -3138,7 +3132,7 @@ class PesterWindow(MovingWindow):
if hasattr(self, 'aboutwindow') and self.aboutwindow:
return
self.aboutwindow = AboutPesterchum(self)
self.aboutwindow.exec_()
self.aboutwindow.exec()
self.aboutwindow = None
@QtCore.pyqtSlot()
def loadCalsprite(self):
@ -3151,15 +3145,15 @@ class PesterWindow(MovingWindow):
self.newConversation("nickServ")
@QtCore.pyqtSlot()
def launchHelp(self):
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/Dpeta/pesterchum-alt-servers/issues", QtCore.QUrl.TolerantMode))
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://forum.homestuck.xyz/viewtopic.php?f=7&t=467", QtCore.QUrl.TolerantMode))
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/Dpeta/pesterchum-alt-servers/issues", QtCore.QUrl.ParsingMode.TolerantMode))
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://forum.homestuck.xyz/viewtopic.php?f=7&t=467", QtCore.QUrl.ParsingMode.TolerantMode))
@QtCore.pyqtSlot()
def reportBug(self):
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/Dpeta/pesterchum-alt-servers/issues", QtCore.QUrl.TolerantMode))
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/Dpeta/pesterchum-alt-servers/issues", QtCore.QUrl.ParsingMode.TolerantMode))
@QtCore.pyqtSlot()
def xyzRules(self):
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://www.pesterchum.xyz/pesterchum-rules", QtCore.QUrl.TolerantMode))
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://www.pesterchum.xyz/pesterchum-rules", QtCore.QUrl.ParsingMode.TolerantMode))
@QtCore.pyqtSlot(QString, QString)
def nickCollision(self, handle, tmphandle):
@ -3186,10 +3180,10 @@ class PesterWindow(MovingWindow):
@QtCore.pyqtSlot(QtWidgets.QSystemTrayIcon.ActivationReason)
def systemTrayActivated(self, reason):
if reason == QtWidgets.QSystemTrayIcon.Trigger:
if reason == QtWidgets.QSystemTrayIcon.ActivationReason.Trigger:
self.systemTrayFunction()
elif reason == QtWidgets.QSystemTrayIcon.Context:
pass
#elif reason == QtWidgets.QSystemTrayIcon.Context:
# pass
# show context menu i guess
#self.showTrayContext.emit()
@ -3236,7 +3230,7 @@ class PesterWindow(MovingWindow):
msgbox.setWindowIcon(PesterIcon(self.theme["main/icon"]))
msgbox.setInformativeText("Incorrect format :(")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.exec_()
msgbox.exec()
self.chooseServer()
return 1
@ -3271,7 +3265,7 @@ class PesterWindow(MovingWindow):
+ "Please tell me if this error occurs :'3")
msgbox.addButton(QtWidgets.QPushButton("Yes"), QtWidgets.QMessageBox.YesRole)
msgbox.addButton(QtWidgets.QPushButton("No"), QtWidgets.QMessageBox.NoRole)
msgbox.exec_()
msgbox.exec()
reply = msgbox.buttonRole(msgbox.clickedButton())
if (reply==QtWidgets.QMessageBox.YesRole):
@ -3645,14 +3639,14 @@ class MainProgram(QtCore.QObject):
moodCategories[k] = moodMenu.addMenu(k.upper())
self.moodactions = {}
for (i,m) in enumerate(Mood.moods):
maction = QtWidgets.QAction(m.upper(), self)
maction = QtGui.QAction(m.upper(), self)
mobj = PesterMoodAction(i, self.widget.moods.updateMood)
maction.triggered.connect(mobj.updateMood)
self.moodactions[i] = mobj
moodCategories[Mood.revmoodcats[m]].addAction(maction)
miniAction = QtWidgets.QAction("MINIMIZE", self)
miniAction = QtGui.QAction("MINIMIZE", self)
miniAction.triggered.connect(self.widget.showMinimized)
exitAction = QtWidgets.QAction("EXIT", self)
exitAction = QtGui.QAction("EXIT", self)
exitAction.triggered.connect(PesterWindow.quit)
self.traymenu.addAction(miniAction)
self.traymenu.addAction(exitAction)
@ -3859,8 +3853,8 @@ Click this message to never see this again.")
widget.loadingscreen.showReconnect()
else:
widget.loadingscreen.hideReconnect()
status = widget.loadingscreen.exec_()
if status == QtWidgets.QDialog.Rejected:
status = widget.loadingscreen.exec()
if status == QtWidgets.QDialog.DialogCode.Rejected:
sys.exit(0)
else:
if self.widget.tabmemo:
@ -3879,7 +3873,7 @@ Click this message to never see this again.")
if not self.reconnectok:
return
if self.widget.loadingscreen:
self.widget.loadingscreen.done(QtWidgets.QDialog.Accepted)
self.widget.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted)
self.widget.loadingscreen = None
self.attempts += 1
if hasattr(self, 'irc') and self.irc:
@ -3930,7 +3924,7 @@ Click this message to never see this again.")
def run(self):
#PchumLog.critical("mreowww") <--- debug thingy :3
sys.exit(self.app.exec_())
sys.exit(self.app.exec())
def _retrieveGlobals():
# NOTE: Yes, this is a terrible kludge so that the console can work

View file

@ -11,7 +11,7 @@ from string import Template
from datetime import datetime
from time import strftime
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
import ostools
from mood import Mood
@ -71,7 +71,7 @@ class PesterLog(object):
errmsg.setText("Warning: Pesterchum could not open the log file for %s!" % (handle))
errmsg.setInformativeText("Your log for %s will not be saved because something went wrong. We suggest restarting Pesterchum. Sorry :(" % (handle))
errmsg.setWindowTitle(":(")
errmsg.exec_()
errmsg.exec()
PchumLog.debug("post-error msg")
self.convos[handle][format] = fp
@ -128,11 +128,11 @@ class userConfig(object):
msgbox = QtWidgets.QMessageBox()
msgbox.setIcon(QtWidgets.QMessageBox.Warning)
msgbox.setWindowTitle(":(")
msgbox.setTextFormat(QtCore.Qt.RichText) # Clickable html links
msgbox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links
msgbox.setInformativeText("<html><h3>Failed to load pesterchum.js, this might require manual intervention.<br><br>\
Consider overriding: <a href='%s'>%s</a> <br>\
with a backup from: <a href='%s'>%s</a></h3></html>" % (_datadir, self.filename, os.path.join(_datadir, "backup"), os.path.join(_datadir, "backup")))
msgbox.exec_()
msgbox.exec()
sys.exit()
# Trying to fix:
@ -472,7 +472,7 @@ with a backup from: <a href='%s'>%s</a></h3></html>" % (_datadir, self.filename,
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Warning)
msgBox.setWindowTitle(":(")
msgBox.setTextFormat(QtCore.Qt.RichText) # Clickable html links
msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links
self.filename = _datadir+"pesterchum.js"
msgBox.setText("<html><h3>Failed to load " + x + ", removed from list." + \
"<br><br>Consider taking a look at: <a href=" + profileloc + ">"+ os.path.join(profileloc, x + ".js") + "</a>" + \
@ -481,7 +481,7 @@ with a backup from: <a href='%s'>%s</a></h3></html>" % (_datadir, self.filename,
#_datadir+"pesterchum.js" + \
#"\"")
PchumLog.critical(e)
msgBox.exec_()
msgBox.exec()
return [userProfile(p) for p in profs]
@ -521,7 +521,7 @@ class userProfile(object):
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Warning)
msgBox.setWindowTitle(":(")
msgBox.setTextFormat(QtCore.Qt.RichText) # Clickable html links
msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links
self.filename = _datadir+"pesterchum.js"
msgBox.setText("<html><h3>Failed to load: " + ("<a href='%s'>%s/%s.js</a>" % (self.profiledir, self.profiledir, user)) + \
"<br><br> Try to check for syntax errors if the file exists." + \
@ -531,7 +531,7 @@ class userProfile(object):
#_datadir+"pesterchum.js" + \
#"\"")
PchumLog.critical(e)
msgBox.exec_()
msgBox.exec()
raise ValueError(e)
try:

View file

@ -1,425 +1,425 @@
import os
import sys
import shutil
import PyInstaller.__main__
is_64bit = sys.maxsize > 2**32
exclude_modules = []
add_data = ['quirks;quirks',
'smilies;smilies',
'themes;themes',
'docs;docs',
'README.md;.',
'LICENSE;.',
'CHANGELOG.md;.',
'PCskins.png;.',
'Pesterchum.png;.']
data_folders = {'quirks': 'quirks',
'smilies': 'smilies',
'themes': 'themes',
'docs': 'docs'}
data_files = {'README.md': 'README.md.txt',
'LICENSE': 'LICENSE.txt',
'CHANGELOG.md': 'CHANGELOG.md.txt',
'PCskins.png': '.',
'Pesterchum.png': '.'}
data_files_linux = {'README.md': 'README.md',
'LICENSE': 'LICENSE.txt',
'CHANGELOG.md': 'CHANGELOG.md',
'PCskins.png': '.',
'Pesterchum.png': '.'}
# Some of these might not be required anymore,
# newer versions of PyInstaller claim to exclude certain problematic DDLs automatically.
upx_exclude = ["qwindows.dll",
"Qt5Core.dll",
"Qt5Gui.dll",
"vcruntime140.dll",
"MSVCP140.dll",
"MSVCP140_1.dll"
"api-ms-win-core-console-l1-1-0.dll",\
"api-ms-win-core-console-l1-1-0.dll",\
"api-ms-win-core-console-l1-2-0.dll",\
"api-ms-win-core-datetime-l1-1-0.dll",\
"api-ms-win-core-debug-l1-1-0.dll",\
"api-ms-win-core-errorhandling-l1-1-0.dll",\
"api-ms-win-core-file-l1-1-0.dll",\
"api-ms-win-core-file-l1-2-0.dll",\
"api-ms-win-core-file-l2-1-0.dll",\
"api-ms-win-core-handle-l1-1-0.dll",\
"api-ms-win-core-heap-l1-1-0.dll",\
"api-ms-win-core-interlocked-l1-1-0.dll",\
"api-ms-win-core-libraryloader-l1-1-0.dll",\
"api-ms-win-core-localization-l1-2-0.dll",\
"api-ms-win-core-memory-l1-1-0.dll",\
"api-ms-win-core-namedpipe-l1-1-0.dll",\
"api-ms-win-core-processenvironment-l1-1-0.dll",\
"api-ms-win-core-processthreads-l1-1-0.dll",\
"api-ms-win-core-processthreads-l1-1-1.dll",\
"api-ms-win-core-profile-l1-1-0.dll",\
"api-ms-win-core-rtlsupport-l1-1-0.dll",\
"api-ms-win-core-string-l1-1-0.dll",\
"api-ms-win-core-synch-l1-1-0.dll",\
"api-ms-win-core-synch-l1-2-0.dll",\
"api-ms-win-core-sysinfo-l1-1-0.dll",\
"api-ms-win-core-timezone-l1-1-0.dll",\
"api-ms-win-core-util-l1-1-0.dll",\
"API-MS-Win-core-xstate-l2-1-0.dll",\
"api-ms-win-crt-conio-l1-1-0.dll",\
"api-ms-win-crt-convert-l1-1-0.dll",\
"api-ms-win-crt-environment-l1-1-0.dll",\
"api-ms-win-crt-filesystem-l1-1-0.dll",\
"api-ms-win-crt-heap-l1-1-0.dll",\
"api-ms-win-crt-locale-l1-1-0.dll",\
"api-ms-win-crt-math-l1-1-0.dll",\
"api-ms-win-crt-multibyte-l1-1-0.dll",\
"api-ms-win-crt-private-l1-1-0.dll",\
"api-ms-win-crt-process-l1-1-0.dll",\
"api-ms-win-crt-runtime-l1-1-0.dll",\
"api-ms-win-crt-stdio-l1-1-0.dll",\
"api-ms-win-crt-string-l1-1-0.dll",\
"api-ms-win-crt-time-l1-1-0.dll",\
"api-ms-win-crt-utility-l1-1-0.dll",\
"ucrtbase.dll"]
delete_builddist = ''
upx_enabled = ''
package_universal_crt = ''
onefile = ''
windowed = ''
try:
print("This is a script to make building with Pyinstaller a bit more conventient.")
while (delete_builddist != 'y') and (delete_builddist != 'n'):
delete_builddist = input("Delete build & dist folders? (Y/N): ").lower()
if delete_builddist == "y":
try:
shutil.rmtree('dist')
except FileNotFoundError as e:
print(e)
try:
shutil.rmtree('build')
except FileNotFoundError as e:
print(e)
while (upx_enabled != 'y') and (upx_enabled != 'n'):
upx_enabled = input("Enable UPX? (Y/N): ").lower()
if upx_enabled == 'y':
print("If upx is on your path you don't need to include anything here.")
if is_64bit == True:
upx_dir = input("UPX directory [D:\\upx-3.96-win64]: ")
if upx_dir == '':
upx_dir = "D:\\upx-3.96-win64" # Default dir for me :)
else:
upx_dir = input("UPX directory [D:\\upx-3.96-win32]: ")
if upx_dir == '':
upx_dir = "D:\\upx-3.96-win32" # Default dir for me :)
print("upx_dir = " + upx_dir)
elif upx_enabled == 'n':
upx_dir = ''
while (windowed != 'y') and (windowed != 'n'):
windowed = input("Build with '--windowed'? (Y/N): ").lower()
if sys.platform == 'win32':
print("(https://pyinstaller.readthedocs.io/en/stable/usage.html?highlight=sdk#windows)")
while (package_universal_crt != 'y') and (package_universal_crt != 'n'):
package_universal_crt = input("Try to include universal CRT? (Y/N): ").lower()
if package_universal_crt == 'y':
if is_64bit == True:
crt_path = input("Universal CRT: [C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x64]: ")
if crt_path == '':
#crt_path = "C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x64" # Default directory.
crt_path = os.path.join('C:%s' % os.sep, 'Program Files (x86)', 'Windows Kits', '10', '10.0.19041.0', 'ucrt', 'DLLs', 'x64')
else:
crt_path = input("Extra path: [C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x86]: ")
if crt_path == '':
#crt_path = "C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x86" # Default directory.
crt_path = os.path.join('C:%s' % os.sep, 'Program Files (x86)', 'Windows Kits', '10', '10.0.19041.0', 'ucrt', 'DLLs', 'x86')
print("crt_path = " + crt_path)
if (sys.platform == 'win32') or (sys.platform == 'linux'):
while (onefile != 'y') and (onefile != 'n'):
onefile = input("Build with '--onefile'? (Y/N): ").lower()
except KeyboardInterrupt:
sys.exit("KeyboardInterrupt")
#Windows
if sys.platform == 'win32':
run_win32 = [
'pesterchum.py',
'--name=Pesterchum',
#'--noconfirm', # Overwrite output directory.
#'--windowed', # Hide console
'--icon=pesterchum.ico',
'--clean', # Clear cache
]
if (sys.version_info.major == 3) & (sys.version_info.minor == 8):
exclude_modules.append('tkinter')
if upx_enabled == 'y':
if os.path.isdir(upx_dir):
run_win32.append('--upx-dir=%s' % upx_dir)
for x in upx_exclude:
run_win32.append('--upx-exclude=%s' % x )
# Lower case variants are required.
run_win32.append('--upx-exclude=%s' % x.lower() )
elif upx_enabled == 'n':
run_win32.append('--noupx')
for x in exclude_modules:
run_win32.append('--exclude-module=%s' % x )
if windowed == 'y':
run_win32.append('--windowed')
if onefile == 'y':
run_win32.append('--onefile')
elif onefile == 'n':
for x in add_data:
run_win32.append('--add-data=%s' % x )
if package_universal_crt == 'y':
run_win32.append('--paths=\"%s\"' % crt_path)
if os.path.exists(crt_path):
if is_64bit == False:
run_win32.append('--add-binary=%s\\api-ms-win-core-console-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-console-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-console-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-datetime-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-debug-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-errorhandling-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-file-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-file-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-file-l2-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-handle-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-heap-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-interlocked-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-libraryloader-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-localization-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-memory-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-namedpipe-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-processenvironment-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-processthreads-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-processthreads-l1-1-1.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-profile-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-rtlsupport-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-string-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-synch-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-synch-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-sysinfo-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-timezone-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-util-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\API-MS-Win-core-xstate-l2-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-conio-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-convert-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-environment-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-filesystem-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-heap-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-locale-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-math-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-multibyte-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-private-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-process-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-runtime-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-stdio-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-string-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-time-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-utility-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\ucrtbase.dll;.' % crt_path)
elif is_64bit == True:
run_win32.append('--add-binary=%s\\api-ms-win-core-console-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-console-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-datetime-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-debug-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-errorhandling-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-file-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-file-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-file-l2-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-handle-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-heap-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-interlocked-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-libraryloader-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-localization-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-memory-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-namedpipe-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-processenvironment-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-processthreads-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-processthreads-l1-1-1.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-profile-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-rtlsupport-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-string-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-synch-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-synch-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-sysinfo-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-timezone-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-util-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-conio-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-convert-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-environment-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-filesystem-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-heap-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-locale-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-math-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-multibyte-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-private-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-process-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-runtime-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-stdio-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-string-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-time-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-utility-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\ucrtbase.dll;.' % crt_path)
print(run_win32)
PyInstaller.__main__.run(run_win32)
if onefile == 'y':
# There's more proper ways to do this, but this doesn't require changing our paths
for x in data_folders:
print(x)
shutil.copytree(x, os.path.join('dist', data_folders[x]),
ignore=shutil.ignore_patterns('*.psd',
'*.xcf*',
'ebg2.png',
'ebg1.png'))
for x in data_files:
print(x)
shutil.copy(x, os.path.join('dist', data_files[x]))
files = os.listdir('dist')
try:
os.mkdir(os.path.join('dist', 'Pesterchum'))
except FileExistsError:
pass
for x in files:
shutil.move(os.path.join('dist',x), os.path.join('dist', 'Pesterchum'))
#shutil.copy(os.path.join('build', 'Pesterchum', 'xref-Pesterchum.html'),
# os.path.join('dist', 'Pesterchum', 'xref-Pesterchum.html'))
#shutil.copy(os.path.join('build', 'Pesterchum', 'Analysis-00.toc'),
# os.path.join('dist', 'Pesterchum', 'Analysis-00.toc'))
#MacOS
elif sys.platform == 'darwin' :
run_darwin =[
'pesterchum.py',
'--name=Pesterchum',
#'--windowed', # Hide console
#'--noconfirm', # Overwrite output directory.
'--icon=trayicon32.icns', # Icon
'--onedir',
'--clean', # Clear cache
#'--noupx'
]
if upx_enabled == 'y':
if os.path.isdir(upx_dir):
run_darwin.append('--upx-dir=%s' % upx_dir)
for x in upx_exclude:
run_darwin.append('--upx-exclude=%s' % x )
# Lower case variants are required.
run_darwin.append('--upx-exclude=%s' % x.lower() )
elif upx_enabled == 'n':
run_darwin.append('--noupx')
if os.path.isdir(upx_dir):
run_darwin.append('--upx-dir=%s' % upx_dir)
for x in exclude_modules:
run_darwin.append('--exclude-module=%s' % x )
for x in add_data:
run_darwin.append('--add-data=%s' % x.replace(';',':') )
if windowed == 'y':
run_darwin.append('--windowed')
PyInstaller.__main__.run(run_darwin)
#Linux
elif sys.platform == 'linux':
run_linux =[
'pesterchum.py',
'--name=Pesterchum',
#'--windowed', # Hide console
#'--noconfirm', # Overwrite output directory.
'--icon=trayicon32.icns', # Icon
'--clean', # Clear cache
]
if upx_enabled == 'y':
if os.path.isdir(upx_dir):
run_linux.append('--upx-dir=%s' % upx_dir)
for x in upx_exclude:
run_linux.append('--upx-exclude=%s' % x )
# Lower case variants are required.
run_linux.append('--upx-exclude=%s' % x.lower() )
elif upx_enabled == 'n':
run_linux.append('--noupx')
for x in exclude_modules:
run_linux.append('--exclude-module=%s' % x )
if onefile == 'y':
run_linux.append('--onefile')
elif onefile == 'n':
for x in add_data:
run_linux.append('--add-data=%s' % x.replace(';',':') )
if windowed == 'y':
run_linux.append('--windowed')
print(run_linux)
PyInstaller.__main__.run(run_linux)
if onefile == 'y':
# There's more proper ways to do this, but this doesn't require changing our paths
for x in data_folders:
print(x)
shutil.copytree(x, os.path.join('dist', data_folders[x]),
ignore=shutil.ignore_patterns('*.psd',
'*.xcf*',
'ebg2.png',
'ebg1.png'))
for x in data_files_linux:
print(x)
shutil.copy(x, os.path.join('dist', data_files_linux[x]))
files = os.listdir('dist')
try:
os.mkdir(os.path.join('dist', '.cache'))
except FileExistsError as e:
print(e)
for x in files:
try:
shutil.move(os.path.join('dist',x), os.path.join('dist', '.cache', x))
except FileExistsError as e:
print(e)
shutil.move(os.path.join('dist', '.cache'), os.path.join('dist', 'Pesterchum'))
#shutil.copy(os.path.join('build', 'Pesterchum', 'xref-Pesterchum.html'),
# os.path.join('dist', 'Pesterchum', 'xref-Pesterchum.html'))
#shutil.copy(os.path.join('build', 'Pesterchum', 'Analysis-00.toc'),
# os.path.join('dist', 'Pesterchum', 'Analysis-00.toc'))
else:
print("Unknown platform.")
run_generic =[
'pesterchum.py',
'--name=Pesterchum'
'--clean', # Clear cache
]
if upx_enabled == 'y':
if os.path.isdir(upx_dir):
run_generic.append('--upx-dir=%s' % upx_dir)
else:
run_generic.append('--noupx')
for x in upx_exclude:
run_generic.append('--upx-exclude=%s' % x )
# Lower case variants are required.
run_generic.append('--upx-exclude=%s' % x.lower() )
for x in exclude_modules:
run_generic.append('--exclude-module=%s' % x )
for x in add_data:
run_generic.append('--add-data=%s' % x.replace(';',':') )
if windowed == 'y':
run_win32.append('--windowed')
print(run_generic)
PyInstaller.__main__.run(run_generic)
import os
import sys
import shutil
import PyInstaller.__main__
is_64bit = sys.maxsize > 2**32
exclude_modules = []
add_data = ['quirks;quirks',
'smilies;smilies',
'themes;themes',
'docs;docs',
'README.md;.',
'LICENSE;.',
'CHANGELOG.md;.',
'PCskins.png;.',
'Pesterchum.png;.']
data_folders = {'quirks': 'quirks',
'smilies': 'smilies',
'themes': 'themes',
'docs': 'docs'}
data_files = {'README.md': 'README.md.txt',
'LICENSE': 'LICENSE.txt',
'CHANGELOG.md': 'CHANGELOG.md.txt',
'PCskins.png': '.',
'Pesterchum.png': '.'}
data_files_linux = {'README.md': 'README.md',
'LICENSE': 'LICENSE.txt',
'CHANGELOG.md': 'CHANGELOG.md',
'PCskins.png': '.',
'Pesterchum.png': '.'}
# Some of these might not be required anymore,
# newer versions of PyInstaller claim to exclude certain problematic DDLs automatically.
upx_exclude = ["qwindows.dll",
"Qt5Core.dll",
"Qt5Gui.dll",
"vcruntime140.dll",
"MSVCP140.dll",
"MSVCP140_1.dll"
"api-ms-win-core-console-l1-1-0.dll",\
"api-ms-win-core-console-l1-1-0.dll",\
"api-ms-win-core-console-l1-2-0.dll",\
"api-ms-win-core-datetime-l1-1-0.dll",\
"api-ms-win-core-debug-l1-1-0.dll",\
"api-ms-win-core-errorhandling-l1-1-0.dll",\
"api-ms-win-core-file-l1-1-0.dll",\
"api-ms-win-core-file-l1-2-0.dll",\
"api-ms-win-core-file-l2-1-0.dll",\
"api-ms-win-core-handle-l1-1-0.dll",\
"api-ms-win-core-heap-l1-1-0.dll",\
"api-ms-win-core-interlocked-l1-1-0.dll",\
"api-ms-win-core-libraryloader-l1-1-0.dll",\
"api-ms-win-core-localization-l1-2-0.dll",\
"api-ms-win-core-memory-l1-1-0.dll",\
"api-ms-win-core-namedpipe-l1-1-0.dll",\
"api-ms-win-core-processenvironment-l1-1-0.dll",\
"api-ms-win-core-processthreads-l1-1-0.dll",\
"api-ms-win-core-processthreads-l1-1-1.dll",\
"api-ms-win-core-profile-l1-1-0.dll",\
"api-ms-win-core-rtlsupport-l1-1-0.dll",\
"api-ms-win-core-string-l1-1-0.dll",\
"api-ms-win-core-synch-l1-1-0.dll",\
"api-ms-win-core-synch-l1-2-0.dll",\
"api-ms-win-core-sysinfo-l1-1-0.dll",\
"api-ms-win-core-timezone-l1-1-0.dll",\
"api-ms-win-core-util-l1-1-0.dll",\
"API-MS-Win-core-xstate-l2-1-0.dll",\
"api-ms-win-crt-conio-l1-1-0.dll",\
"api-ms-win-crt-convert-l1-1-0.dll",\
"api-ms-win-crt-environment-l1-1-0.dll",\
"api-ms-win-crt-filesystem-l1-1-0.dll",\
"api-ms-win-crt-heap-l1-1-0.dll",\
"api-ms-win-crt-locale-l1-1-0.dll",\
"api-ms-win-crt-math-l1-1-0.dll",\
"api-ms-win-crt-multibyte-l1-1-0.dll",\
"api-ms-win-crt-private-l1-1-0.dll",\
"api-ms-win-crt-process-l1-1-0.dll",\
"api-ms-win-crt-runtime-l1-1-0.dll",\
"api-ms-win-crt-stdio-l1-1-0.dll",\
"api-ms-win-crt-string-l1-1-0.dll",\
"api-ms-win-crt-time-l1-1-0.dll",\
"api-ms-win-crt-utility-l1-1-0.dll",\
"ucrtbase.dll"]
delete_builddist = ''
upx_enabled = ''
package_universal_crt = ''
onefile = ''
windowed = ''
try:
print("This is a script to make building with Pyinstaller a bit more conventient.")
while (delete_builddist != 'y') and (delete_builddist != 'n'):
delete_builddist = input("Delete build & dist folders? (Y/N): ").lower()
if delete_builddist == "y":
try:
shutil.rmtree('dist')
except FileNotFoundError as e:
print(e)
try:
shutil.rmtree('build')
except FileNotFoundError as e:
print(e)
while (upx_enabled != 'y') and (upx_enabled != 'n'):
upx_enabled = input("Enable UPX? (Y/N): ").lower()
if upx_enabled == 'y':
print("If upx is on your path you don't need to include anything here.")
if is_64bit == True:
upx_dir = input("UPX directory [D:\\upx-3.96-win64]: ")
if upx_dir == '':
upx_dir = "D:\\upx-3.96-win64" # Default dir for me :)
else:
upx_dir = input("UPX directory [D:\\upx-3.96-win32]: ")
if upx_dir == '':
upx_dir = "D:\\upx-3.96-win32" # Default dir for me :)
print("upx_dir = " + upx_dir)
elif upx_enabled == 'n':
upx_dir = ''
while (windowed != 'y') and (windowed != 'n'):
windowed = input("Build with '--windowed'? (Y/N): ").lower()
if sys.platform == 'win32':
print("(https://pyinstaller.readthedocs.io/en/stable/usage.html?highlight=sdk#windows)")
while (package_universal_crt != 'y') and (package_universal_crt != 'n'):
package_universal_crt = input("Try to include universal CRT? (Y/N): ").lower()
if package_universal_crt == 'y':
if is_64bit == True:
crt_path = input("Universal CRT: [C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x64]: ")
if crt_path == '':
#crt_path = "C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x64" # Default directory.
crt_path = os.path.join('C:%s' % os.sep, 'Program Files (x86)', 'Windows Kits', '10', '10.0.19041.0', 'ucrt', 'DLLs', 'x64')
else:
crt_path = input("Extra path: [C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x86]: ")
if crt_path == '':
#crt_path = "C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x86" # Default directory.
crt_path = os.path.join('C:%s' % os.sep, 'Program Files (x86)', 'Windows Kits', '10', '10.0.19041.0', 'ucrt', 'DLLs', 'x86')
print("crt_path = " + crt_path)
if (sys.platform == 'win32') or (sys.platform == 'linux'):
while (onefile != 'y') and (onefile != 'n'):
onefile = input("Build with '--onefile'? (Y/N): ").lower()
except KeyboardInterrupt:
sys.exit("KeyboardInterrupt")
#Windows
if sys.platform == 'win32':
run_win32 = [
'pesterchum.py',
'--name=Pesterchum',
#'--noconfirm', # Overwrite output directory.
#'--windowed', # Hide console
'--icon=pesterchum.ico',
'--clean', # Clear cache
]
if (sys.version_info.major == 3) & (sys.version_info.minor == 8):
exclude_modules.append('tkinter')
if upx_enabled == 'y':
if os.path.isdir(upx_dir):
run_win32.append('--upx-dir=%s' % upx_dir)
for x in upx_exclude:
run_win32.append('--upx-exclude=%s' % x )
# Lower case variants are required.
run_win32.append('--upx-exclude=%s' % x.lower() )
elif upx_enabled == 'n':
run_win32.append('--noupx')
for x in exclude_modules:
run_win32.append('--exclude-module=%s' % x )
if windowed == 'y':
run_win32.append('--windowed')
if onefile == 'y':
run_win32.append('--onefile')
elif onefile == 'n':
for x in add_data:
run_win32.append('--add-data=%s' % x )
if package_universal_crt == 'y':
run_win32.append('--paths=\"%s\"' % crt_path)
if os.path.exists(crt_path):
if is_64bit == False:
run_win32.append('--add-binary=%s\\api-ms-win-core-console-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-console-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-console-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-datetime-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-debug-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-errorhandling-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-file-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-file-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-file-l2-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-handle-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-heap-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-interlocked-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-libraryloader-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-localization-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-memory-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-namedpipe-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-processenvironment-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-processthreads-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-processthreads-l1-1-1.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-profile-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-rtlsupport-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-string-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-synch-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-synch-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-sysinfo-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-timezone-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-util-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\API-MS-Win-core-xstate-l2-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-conio-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-convert-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-environment-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-filesystem-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-heap-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-locale-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-math-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-multibyte-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-private-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-process-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-runtime-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-stdio-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-string-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-time-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-utility-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\ucrtbase.dll;.' % crt_path)
elif is_64bit == True:
run_win32.append('--add-binary=%s\\api-ms-win-core-console-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-console-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-datetime-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-debug-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-errorhandling-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-file-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-file-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-file-l2-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-handle-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-heap-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-interlocked-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-libraryloader-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-localization-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-memory-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-namedpipe-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-processenvironment-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-processthreads-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-processthreads-l1-1-1.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-profile-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-rtlsupport-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-string-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-synch-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-synch-l1-2-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-sysinfo-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-timezone-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-core-util-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-conio-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-convert-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-environment-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-filesystem-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-heap-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-locale-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-math-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-multibyte-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-private-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-process-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-runtime-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-stdio-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-string-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-time-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\api-ms-win-crt-utility-l1-1-0.dll;.' % crt_path)
run_win32.append('--add-binary=%s\\ucrtbase.dll;.' % crt_path)
print(run_win32)
PyInstaller.__main__.run(run_win32)
if onefile == 'y':
# There's more proper ways to do this, but this doesn't require changing our paths
for x in data_folders:
print(x)
shutil.copytree(x, os.path.join('dist', data_folders[x]),
ignore=shutil.ignore_patterns('*.psd',
'*.xcf*',
'ebg2.png',
'ebg1.png'))
for x in data_files:
print(x)
shutil.copy(x, os.path.join('dist', data_files[x]))
files = os.listdir('dist')
try:
os.mkdir(os.path.join('dist', 'Pesterchum'))
except FileExistsError:
pass
for x in files:
shutil.move(os.path.join('dist',x), os.path.join('dist', 'Pesterchum'))
#shutil.copy(os.path.join('build', 'Pesterchum', 'xref-Pesterchum.html'),
# os.path.join('dist', 'Pesterchum', 'xref-Pesterchum.html'))
#shutil.copy(os.path.join('build', 'Pesterchum', 'Analysis-00.toc'),
# os.path.join('dist', 'Pesterchum', 'Analysis-00.toc'))
#MacOS
elif sys.platform == 'darwin' :
run_darwin =[
'pesterchum.py',
'--name=Pesterchum',
#'--windowed', # Hide console
#'--noconfirm', # Overwrite output directory.
'--icon=trayicon32.icns', # Icon
'--onedir',
'--clean', # Clear cache
#'--noupx'
]
if upx_enabled == 'y':
if os.path.isdir(upx_dir):
run_darwin.append('--upx-dir=%s' % upx_dir)
for x in upx_exclude:
run_darwin.append('--upx-exclude=%s' % x )
# Lower case variants are required.
run_darwin.append('--upx-exclude=%s' % x.lower() )
elif upx_enabled == 'n':
run_darwin.append('--noupx')
if os.path.isdir(upx_dir):
run_darwin.append('--upx-dir=%s' % upx_dir)
for x in exclude_modules:
run_darwin.append('--exclude-module=%s' % x )
for x in add_data:
run_darwin.append('--add-data=%s' % x.replace(';',':') )
if windowed == 'y':
run_darwin.append('--windowed')
PyInstaller.__main__.run(run_darwin)
#Linux
elif sys.platform == 'linux':
run_linux =[
'pesterchum.py',
'--name=Pesterchum',
#'--windowed', # Hide console
#'--noconfirm', # Overwrite output directory.
'--icon=trayicon32.icns', # Icon
'--clean', # Clear cache
]
if upx_enabled == 'y':
if os.path.isdir(upx_dir):
run_linux.append('--upx-dir=%s' % upx_dir)
for x in upx_exclude:
run_linux.append('--upx-exclude=%s' % x )
# Lower case variants are required.
run_linux.append('--upx-exclude=%s' % x.lower() )
elif upx_enabled == 'n':
run_linux.append('--noupx')
for x in exclude_modules:
run_linux.append('--exclude-module=%s' % x )
if onefile == 'y':
run_linux.append('--onefile')
elif onefile == 'n':
for x in add_data:
run_linux.append('--add-data=%s' % x.replace(';',':') )
if windowed == 'y':
run_linux.append('--windowed')
print(run_linux)
PyInstaller.__main__.run(run_linux)
if onefile == 'y':
# There's more proper ways to do this, but this doesn't require changing our paths
for x in data_folders:
print(x)
shutil.copytree(x, os.path.join('dist', data_folders[x]),
ignore=shutil.ignore_patterns('*.psd',
'*.xcf*',
'ebg2.png',
'ebg1.png'))
for x in data_files_linux:
print(x)
shutil.copy(x, os.path.join('dist', data_files_linux[x]))
files = os.listdir('dist')
try:
os.mkdir(os.path.join('dist', '.cache'))
except FileExistsError as e:
print(e)
for x in files:
try:
shutil.move(os.path.join('dist',x), os.path.join('dist', '.cache', x))
except FileExistsError as e:
print(e)
shutil.move(os.path.join('dist', '.cache'), os.path.join('dist', 'Pesterchum'))
#shutil.copy(os.path.join('build', 'Pesterchum', 'xref-Pesterchum.html'),
# os.path.join('dist', 'Pesterchum', 'xref-Pesterchum.html'))
#shutil.copy(os.path.join('build', 'Pesterchum', 'Analysis-00.toc'),
# os.path.join('dist', 'Pesterchum', 'Analysis-00.toc'))
else:
print("Unknown platform.")
run_generic =[
'pesterchum.py',
'--name=Pesterchum'
'--clean', # Clear cache
]
if upx_enabled == 'y':
if os.path.isdir(upx_dir):
run_generic.append('--upx-dir=%s' % upx_dir)
else:
run_generic.append('--noupx')
for x in upx_exclude:
run_generic.append('--upx-exclude=%s' % x )
# Lower case variants are required.
run_generic.append('--upx-exclude=%s' % x.lower() )
for x in exclude_modules:
run_generic.append('--exclude-module=%s' % x )
for x in add_data:
run_generic.append('--add-data=%s' % x.replace(';',':') )
if windowed == 'y':
run_win32.append('--windowed')
print(run_generic)
PyInstaller.__main__.run(run_generic)

View file

@ -2,7 +2,7 @@ import logging
import logging.config
import importlib.util
from PyQt5 import QtWidgets
from PyQt6 import QtWidgets
import ostools
from quirks import ScriptQuirks
@ -51,7 +51,7 @@ class PythonQuirks(ScriptQuirks):
msgbox = QtWidgets.QMessageBox()
msgbox.setWindowTitle("Error!")
msgbox.setText("Quirk malformed: %s" % (obj.command))
msgbox.exec_()
msgbox.exec()
else:
self.quirks[obj.command] = obj

View file

@ -78,7 +78,7 @@ class ScriptQuirks(object):
#msgbox = QtWidgets.QMessageBox()
#msgbox.setWindowTitle("Error!")
#msgbox.setText("Error loading %s: %s (in quirks.py)" % (os.path.basename(filename), e))
#msgbox.exec_()
#msgbox.exec()
else:
if self.modHas(module, 'setup'):
module.setup()

View file

@ -1,7 +1,7 @@
import logging
import logging.config
from PyQt5 import QtCore, QtWidgets
from PyQt6 import QtCore, QtWidgets
import ostools
@ -70,7 +70,7 @@ class RandomHandler(QtCore.QObject):
msgbox = QtWidgets.QMessageBox()
msgbox.setText("Unable to fetch you a random encounter!")
msgbox.setInformativeText("Try again later :(")
msgbox.exec_()
msgbox.exec()
return
name = str(l[1])
PchumLog.info("Random Encounter name is: " + name)

276
setup.py
View file

@ -1,138 +1,138 @@
# Windows-only cx_freeze setup file, macOS may work but I've not tested it.
import sys
from cx_Freeze import setup, Executable
import pygame
from version import buildVersion
if sys.version_info < (3, 0, 0):
sys.exit("Python versions lower than 3 are not supported.")
def is_64bit() -> bool:
return sys.maxsize > 2**32
path = ""
base = None
if sys.platform == "win32":
base = "Win32GUI"
path = sys.path
if is_64bit() == True:
path.append(r"C:\Program Files (x86)\Windows Kits\10\Redist\10.0.22000.0\ucrt\DLLs\x64")
elif is_64bit() == False:
path.append(r"C:\Program Files (x86)\Windows Kits\10\Redist\10.0.22000.0\ucrt\DLLs\x86")
print("Path = " + str(path))
includefiles = ["quirks",
"smilies",
"themes",
"docs",
"README.md",
"LICENSE",
"CHANGELOG.md",
"PCskins.png",
"Pesterchum.png"]
build_exe_options = {
"includes": ['PyQt5.QtCore',
'PyQt5.QtGui',
'PyQt5.QtWidgets'],
"excludes": ['collections.sys',
'collections._sre',
'collections._json',
'collections._locale',
'collections._struct',
'collections.array',
'collections._weakref',
'PyQt5.QtMultimedia',
'PyQt5.QtDBus',
'PyQt5.QtDeclarative',
'PyQt5.QtHelp',
'PyQt5.QtNetwork',
'PyQt5.QtSql',
'PyQt5.QtSvg',
'PyQt5.QtTest',
'PyQt5.QtWebKit',
'PyQt5.QtXml',
'PyQt5.QtXmlPatterns',
'PyQt5.phonon',
'PyQt5.QtAssistant',
'PyQt5.QtDesigner',
'PyQt5.QAxContainer',
'pygame.docs' # Hopefully we can just not have pygame at all at some point =3
# (when QtMultimedia stops relying on local codecs </3)
'pygame.examples',
'pygame.tests',
'pydoc_data'],
"include_files": includefiles,
"include_msvcr": True, # cx_freeze copies 64-bit binaries always?
"path": path # Improved in 6.6, path to be safe
# VCRUNTIME140.dll <3
}
if (sys.platform == 'win32') & (sys.version_info.major == 3) & (sys.version_info.minor == 8):
build_exe_options["excludes"].append('tkinter')
bdist_mac_options = {
'iconfile': 'trayicon32.icns',
'bundle_name': "Pesterchum"
}
description = "Pesterchum"
icon = "pesterchum.ico"
# See https://stackoverflow.com/questions/15734703/use-cx-freeze-to-create-an-msi-that-adds-a-shortcut-to-the-desktop
shortcut_table = [
("DesktopShortcut", # Shortcut
"DesktopFolder", # Directory_
"Pesterchum", # Name
"TARGETDIR", # Component_
"[TARGETDIR]pesterchum.exe",# Target
None, # Arguments
description, # Description
None, # Hotkey
None, # Icon (Is inherited from pesterchum.exe)
None, # IconIndex
None, # ShowCmd
'TARGETDIR' # WkDir
),
("StartMenuShortcut", # Shortcut
"StartMenuFolder", # Directory_
"Pesterchum", # Name
"TARGETDIR", # Component_
"[TARGETDIR]pesterchum.exe",# Target
None, # Arguments
description, # Description
None, # Hotkey
None, # Icon
None, # IconIndex
None, # ShowCmd
'TARGETDIR' # WkDir
)
]
msi_data = {"Shortcut": shortcut_table}
bdist_msi_options = {'data': msi_data,
'summary_data': {
'comments': "FL1P",
'keywords': "Pesterchum"},
'upgrade_code': "{86740d75-f1f2-48e8-8266-f36395a2d77f}",
'add_to_path': False, # !!!
'all_users': False,
'install_icon': "pesterchum.ico"}
setup(
name = "Pesterchum",
version = buildVersion,
url = "https://github.com/Dpeta/pesterchum-alt-servers",
description = description,#"P3ST3RCHUM",
options = {"build_exe": build_exe_options,
"bdist_msi": bdist_msi_options,
"bdist_mac": bdist_mac_options},
packages="",
executables = [Executable("pesterchum.py",
base=base,
icon=icon
)])
# Windows-only cx_freeze setup file, macOS may work but I've not tested it.
import sys
from cx_Freeze import setup, Executable
import pygame
from version import buildVersion
if sys.version_info < (3, 0, 0):
sys.exit("Python versions lower than 3 are not supported.")
def is_64bit() -> bool:
return sys.maxsize > 2**32
path = ""
base = None
if sys.platform == "win32":
base = "Win32GUI"
path = sys.path
if is_64bit() == True:
path.append(r"C:\Program Files (x86)\Windows Kits\10\Redist\10.0.22000.0\ucrt\DLLs\x64")
elif is_64bit() == False:
path.append(r"C:\Program Files (x86)\Windows Kits\10\Redist\10.0.22000.0\ucrt\DLLs\x86")
print("Path = " + str(path))
includefiles = ["quirks",
"smilies",
"themes",
"docs",
"README.md",
"LICENSE",
"CHANGELOG.md",
"PCskins.png",
"Pesterchum.png"]
build_exe_options = {
"includes": ['PyQt6.QtCore',
'PyQt6.QtGui',
'PyQt6.QtWidgets'],
"excludes": ['collections.sys',
'collections._sre',
'collections._json',
'collections._locale',
'collections._struct',
'collections.array',
'collections._weakref',
'PyQt6.QtMultimedia',
'PyQt6.QtDBus',
'PyQt6.QtDeclarative',
'PyQt6.QtHelp',
'PyQt6.QtNetwork',
'PyQt6.QtSql',
'PyQt6.QtSvg',
'PyQt6.QtTest',
'PyQt6.QtWebKit',
'PyQt6.QtXml',
'PyQt6.QtXmlPatterns',
'PyQt6.phonon',
'PyQt6.QtAssistant',
'PyQt6.QtDesigner',
'PyQt6.QAxContainer',
'pygame.docs' # Hopefully we can just not have pygame at all at some point =3
# (when QtMultimedia stops relying on local codecs </3)
'pygame.examples',
'pygame.tests',
'pydoc_data'],
"include_files": includefiles,
"include_msvcr": True, # cx_freeze copies 64-bit binaries always?
"path": path # Improved in 6.6, path to be safe
# VCRUNTIME140.dll <3
}
if (sys.platform == 'win32') & (sys.version_info.major == 3) & (sys.version_info.minor == 8):
build_exe_options["excludes"].append('tkinter')
bdist_mac_options = {
'iconfile': 'trayicon32.icns',
'bundle_name': "Pesterchum"
}
description = "Pesterchum"
icon = "pesterchum.ico"
# See https://stackoverflow.com/questions/15734703/use-cx-freeze-to-create-an-msi-that-adds-a-shortcut-to-the-desktop
shortcut_table = [
("DesktopShortcut", # Shortcut
"DesktopFolder", # Directory_
"Pesterchum", # Name
"TARGETDIR", # Component_
"[TARGETDIR]pesterchum.exe",# Target
None, # Arguments
description, # Description
None, # Hotkey
None, # Icon (Is inherited from pesterchum.exe)
None, # IconIndex
None, # ShowCmd
'TARGETDIR' # WkDir
),
("StartMenuShortcut", # Shortcut
"StartMenuFolder", # Directory_
"Pesterchum", # Name
"TARGETDIR", # Component_
"[TARGETDIR]pesterchum.exe",# Target
None, # Arguments
description, # Description
None, # Hotkey
None, # Icon
None, # IconIndex
None, # ShowCmd
'TARGETDIR' # WkDir
)
]
msi_data = {"Shortcut": shortcut_table}
bdist_msi_options = {'data': msi_data,
'summary_data': {
'comments': "FL1P",
'keywords': "Pesterchum"},
'upgrade_code': "{86740d75-f1f2-48e8-8266-f36395a2d77f}",
'add_to_path': False, # !!!
'all_users': False,
'install_icon': "pesterchum.ico"}
setup(
name = "Pesterchum",
version = buildVersion,
url = "https://github.com/Dpeta/pesterchum-alt-servers",
description = description,#"P3ST3RCHUM",
options = {"build_exe": build_exe_options,
"bdist_msi": bdist_msi_options,
"bdist_mac": bdist_mac_options},
packages="",
executables = [Executable("pesterchum.py",
base=base,
icon=icon
)])

View file

@ -4,7 +4,7 @@ import inspect
import logging
import logging.config
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
import ostools
@ -197,19 +197,19 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
self.time = time
if ostools.isWin32():
self.setWindowFlags(QtCore.Qt.ToolTip)
self.setWindowFlags(QtCore.Qt.WindowType.ToolTip)
else:
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.ToolTip)
self.setWindowFlags(QtCore.Qt.WindowType.WindowStaysOnTopHint | QtCore.Qt.WindowType.X11BypassWindowManagerHint | QtCore.Qt.WindowType.ToolTip)
self.m_animation = QtCore.QParallelAnimationGroup()
anim = QtCore.QPropertyAnimation(self)
anim.setTargetObject(self)
self.m_animation.addAnimation(anim)
anim.setEasingCurve(QtCore.QEasingCurve.OutBounce)
anim.setEasingCurve(QtCore.QEasingCurve.Type.OutBounce)
anim.setDuration(1000)
anim.finished.connect(self.reverseTrigger)
self.m_animation.setDirection(QtCore.QAnimationGroup.Forward)
self.m_animation.setDirection(QtCore.QAbstractAnimation.Direction.Forward)
self.title = QtWidgets.QLabel(title, self)
self.msg = QtWidgets.QLabel(msg, self)
@ -230,7 +230,7 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
layout_1 = QtWidgets.QGridLayout()
layout_1.addWidget(self.icon, 0,0, 1,1)
layout_1.addWidget(self.title, 0,1, 1,7)
layout_1.setAlignment(self.msg, QtCore.Qt.AlignTop)
layout_1.setAlignment(self.msg, QtCore.Qt.AlignmentFlag.AlignTop)
layout_0.addLayout(layout_1)
else:
layout_0.addWidget(self.title)
@ -252,11 +252,13 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
self.msg.setText(PesterToast.wrapText(self.msg.font(), str(self.msg.text()), self.parent().theme["toasts/width"], self.parent().theme["toasts/content/style"]))
p = QtWidgets.QApplication.desktop().availableGeometry(self).bottomRight()
o = QtWidgets.QApplication.desktop().screenGeometry(self).bottomRight()
anim.setStartValue(p.y() - o.y())
anim.setEndValue(100)
anim.valueChanged[QtCore.QVariant].connect(self.updateBottomLeftAnimation)
for screen in QtWidgets.QApplication.screens():
# This 100% doesn't work with multiple screens.
p = screen.availableGeometry().bottomRight()
o = screen.geometry().bottomRight()
anim.setStartValue(p.y() - o.y())
anim.setEndValue(100)
anim.valueChanged[QtCore.QVariant].connect(self.updateBottomLeftAnimation)
self.byebye = False
@ -286,15 +288,17 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
if not self.byebye:
self.byebye = True
anim = self.m_animation.animationAt(0)
self.m_animation.setDirection(QtCore.QAnimationGroup.Backward)
anim.setEasingCurve(QtCore.QEasingCurve.InCubic)
self.m_animation.setDirection(QtCore.QAbstractAnimation.Direction.Backward)
anim.setEasingCurve(QtCore.QEasingCurve.Type.InCubic)
anim.finished.disconnect(self.reverseTrigger)
anim.finished.connect(self.done)
self.m_animation.start()
@QtCore.pyqtSlot(QtCore.QVariant)
def updateBottomLeftAnimation(self, value):
p = QtWidgets.QApplication.desktop().availableGeometry(self).bottomRight()
#p = QtWidgets.QApplication.desktop().availableGeometry(self).bottomRight()
for screen in QtWidgets.QApplication.screens():
p = screen.availableGeometry().bottomRight()
val = (self.height())/100
# Does type casting this to an int have any negative consequences?
self.move(int(p.x()-self.width()), int(p.y() - (value * val) +1))
@ -302,9 +306,9 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
QtWidgets.QWidget.show(self)
def mousePressEvent(self, event):
if event.button() == QtCore.Qt.RightButton:
if event.button() == QtCore.Qt.MouseButton.RightButton:
self.reverseStart()
elif event.button() == QtCore.Qt.LeftButton:
elif event.button() == QtCore.Qt.MouseButton.LeftButton:
pass
@staticmethod
@ -351,20 +355,20 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
if stuff.isdigit():
maxwidth -= int(stuff)
if metric.width(text) < maxwidth:
if metric.horizontalAdvance(text) < maxwidth:
return text
while metric.width(text) > maxwidth:
while metric.horizontalAdvance(text) > maxwidth:
lastspace = text.find(" ")
curspace = lastspace
while metric.width(text, curspace) < maxwidth:
while metric.horizontalAdvance(text, curspace) < maxwidth:
lastspace = curspace
curspace = text.find(" ", lastspace+1)
if curspace == -1:
break
if (metric.width(text[:lastspace]) > maxwidth) or \
if (metric.horizontalAdvance(text[:lastspace]) > maxwidth) or \
len(text[:lastspace]) < 1:
for i in range(len(text)):
if metric.width(text[:i]) > maxwidth:
if metric.horizontalAdvance(text[:i]) > maxwidth:
lastspace = i-1
break
ret.append(text[:lastspace])