VertexEngine 1.2rc4__4-py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ from PyQt6.QtWidgets import QCheckBox
2
+ class VCheckBox(QCheckBox):
3
+ def __init__(self, text=""):
4
+ super().__init__(text)
5
+
6
+ def on_toggle(self, callback):
7
+ self.stateChanged.connect(callback)
8
+ return self
@@ -0,0 +1,12 @@
1
+ from PyQt6.QtWidgets import QComboBox
2
+
3
+ class VDropdown(QComboBox):
4
+ def __init__(self, items=None):
5
+ super().__init__()
6
+
7
+ if items:
8
+ self.addItems(items)
9
+
10
+ def on_select(self, callback):
11
+ self.currentTextChanged.connect(callback)
12
+ return self
@@ -0,0 +1,12 @@
1
+ from PyQt6.QtWidgets import QListWidget
2
+
3
+ class VList(QListWidget):
4
+ def __init__(self, items=None):
5
+ super().__init__()
6
+
7
+ if items:
8
+ self.addItems(items)
9
+
10
+ def on_click(self, callback):
11
+ self.itemClicked.connect(callback)
12
+ return self
@@ -0,0 +1,71 @@
1
+ from PyQt6.QtWidgets import (
2
+ QTreeWidget, QTreeWidgetItem,
3
+ QTableWidget, QTableWidgetItem,
4
+ QSplitter,
5
+ QScrollArea,
6
+ QDockWidget,
7
+ QGraphicsView, QGraphicsScene,
8
+ )
9
+ from PyQt6.QtGui import QKeySequence, QShortcut
10
+ from PyQt6.QtCore import Qt, QThread, pyqtSignal, QSettings
11
+ from PyQt6.QtWebEngineWidgets import QWebEngineView
12
+
13
+ class VTree(QTreeWidget):
14
+ def __init__(self, headers=["Name"]):
15
+ super().__init__()
16
+ self.setHeaderLabels(headers)
17
+
18
+ def add_item(self, text):
19
+ item = QTreeWidgetItem([text])
20
+ self.addTopLevelItem(item)
21
+ return item
22
+
23
+ class VTable(QTableWidget):
24
+ def __init__(self, rows=0, cols=0):
25
+ super().__init__(rows, cols)
26
+
27
+ def set_cell(self, row, col, text):
28
+ self.setItem(row, col, QTableWidgetItem(str(text)))
29
+
30
+ class VSplitter(QSplitter):
31
+ def __init__(self, orientation="horizontal"):
32
+ orient = Qt.Orientation.Horizontal if orientation == "horizontal" else Qt.Orientation.Vertical
33
+ super().__init__(orient)
34
+
35
+ def add(self, widget):
36
+ self.addWidget(widget)
37
+
38
+ class VScroll(QScrollArea):
39
+ def __init__(self, widget=None):
40
+ super().__init__()
41
+
42
+ if widget:
43
+ self.setWidget(widget)
44
+
45
+ self.setWidgetResizable(True)
46
+
47
+ class VDock(QDockWidget):
48
+ def __init__(self, title="Dock"):
49
+ super().__init__(title)
50
+
51
+ def set(self, widget):
52
+ self.setWidget(widget)
53
+
54
+
55
+ class VThread(QThread):
56
+ finished = pyqtSignal(str)
57
+
58
+ def run(self):
59
+ import time
60
+ time.sleep(2)
61
+ self.finished.emit("Thread Complete!")
62
+
63
+ class VSettings(QSettings):
64
+ def __init__(self, organization="VertexEngine", name="App"):
65
+ super().__init__(organization, name)
66
+
67
+ def save(self, key, value):
68
+ self.setValue(key, value)
69
+
70
+ def load(self, key, default=None):
71
+ return self.value(key, default)
@@ -0,0 +1,66 @@
1
+ from PyQt6.QtWidgets import QMessageBox, QFileDialog, QSlider, QProgressBar, QSpinBox, QToolBar
2
+ from PyQt6.QtCore import Qt
3
+ from PyQt6.QtGui import QAction
4
+ class VPopup:
5
+ @staticmethod
6
+ def info(text, title="Info"):
7
+ QMessageBox.information(None, title, text)
8
+
9
+ @staticmethod
10
+ def error(text, title="Error"):
11
+ QMessageBox.critical(None, title, text)
12
+
13
+ class VFilePicker:
14
+ @staticmethod
15
+ def open_file():
16
+ file, _ = QFileDialog.getOpenFileName(None, "Open File")
17
+ return file
18
+
19
+ @staticmethod
20
+ def save_file():
21
+ file, _ = QFileDialog.getSaveFileName(None, "Save File")
22
+ return file
23
+
24
+ class VSlider(QSlider):
25
+ def __init__(self, min=0, max=100):
26
+ super().__init__(Qt.Orientation.Horizontal)
27
+
28
+ self.setMinimum(min)
29
+ self.setMaximum(max)
30
+
31
+ def on_change(self, callback):
32
+ self.valueChanged.connect(callback)
33
+ return self
34
+
35
+ class VProgress(QProgressBar):
36
+ def __init__(self):
37
+ super().__init__()
38
+ self.setValue(0)
39
+
40
+ def set(self, value):
41
+ self.setValue(value)
42
+
43
+ class VSpinBox(QSpinBox):
44
+ def __init__(self, min=0, max=100):
45
+ super().__init__()
46
+ self.setRange(min, max)
47
+
48
+ def on_change(self, callback):
49
+ self.valueChanged.connect(callback)
50
+ return self
51
+
52
+ class VToolBar(QToolBar):
53
+ def __init__(self, name="Toolbar"):
54
+ super().__init__(name)
55
+
56
+ def add_button(self, text, callback):
57
+ action = VertexAction(text, self)
58
+ action.triggered.connect(callback)
59
+ self.addAction(action)
60
+
61
+ class VertexAction(QAction):
62
+ def __init__(self, text, callback=None):
63
+ super().__init__(text)
64
+
65
+ if callback:
66
+ self.triggered.connect(callback)
@@ -0,0 +1,63 @@
1
+ from PyQt6.QtCore import Qt
2
+
3
+
4
+ class Mouse:
5
+ _map = {
6
+ "left": Qt.MouseButton.LeftButton,
7
+ "right": Qt.MouseButton.RightButton,
8
+ "middle": Qt.MouseButton.MiddleButton,
9
+ "x1": Qt.MouseButton.BackButton,
10
+ "x2": Qt.MouseButton.ForwardButton,
11
+ }
12
+
13
+ @staticmethod
14
+ def resolve(btn):
15
+ if isinstance(btn, str):
16
+ btn = Mouse._map.get(btn.lower())
17
+ if btn is None:
18
+ raise KeyError(f"Unknown mouse button: {btn}")
19
+ return btn
20
+
21
+
22
+ class MouseEvents:
23
+ def __init__(self):
24
+ self.current = set()
25
+ self.last = set()
26
+
27
+ self.on_press_events = {}
28
+ self.on_release_events = {}
29
+ self.on_hold_events = {}
30
+
31
+ def update_from_qt(self, qt_buttons):
32
+ self.current.clear()
33
+ for btn in Mouse._map.values():
34
+ if qt_buttons & btn:
35
+ self.current.add(btn)
36
+
37
+ def update(self):
38
+ for btn in self.current - self.last:
39
+ for f in self.on_press_events.get(btn, []):
40
+ f()
41
+
42
+ for btn in self.last - self.current:
43
+ for f in self.on_release_events.get(btn, []):
44
+ f()
45
+
46
+ for btn in self.current:
47
+ for f in self.on_hold_events.get(btn, []):
48
+ f()
49
+
50
+ self.last = self.current.copy()
51
+
52
+ def on_press(self, btn, func):
53
+ self.on_press_events.setdefault(Mouse.resolve(btn), []).append(func)
54
+
55
+ def on_release(self, btn, func):
56
+ self.on_release_events.setdefault(Mouse.resolve(btn), []).append(func)
57
+
58
+ def on_hold(self, btn, func):
59
+ self.on_hold_events.setdefault(Mouse.resolve(btn), []).append(func)
60
+
61
+ def clear(self):
62
+ self.current.clear()
63
+ self.last.clear()
@@ -0,0 +1,73 @@
1
+ from PyQt6.QtCore import QTimer, QObject, QEvent
2
+
3
+
4
+ class ButtonEvents:
5
+ def __init__(self):
6
+ self._timers = {}
7
+ self._filters = {}
8
+
9
+ def on_click(self, button, action, *args, **kwargs):
10
+ button.clicked.connect(lambda: action(*args, **kwargs))
11
+
12
+ def on_double_click(self, button, action, interval=250):
13
+ timer = QTimer(button)
14
+ timer.setSingleShot(True)
15
+ self._timers[(button, "double")] = timer
16
+
17
+ def handler():
18
+ if timer.isActive():
19
+ timer.stop()
20
+ action()
21
+ else:
22
+ timer.start(interval)
23
+
24
+ button.clicked.connect(handler)
25
+
26
+ def on_long_press(self, button, action, duration=600):
27
+ timer = QTimer(button)
28
+ timer.setSingleShot(True)
29
+ timer.timeout.connect(action)
30
+ self._timers[(button, "long")] = timer
31
+
32
+ button.pressed.connect(lambda: timer.start(duration))
33
+ button.released.connect(timer.stop)
34
+
35
+ def on_click_debounced(self, button, action, cooldown=500):
36
+ timer = QTimer(button)
37
+ timer.setSingleShot(True)
38
+ self._timers[(button, "debounce")] = timer
39
+
40
+ def handler():
41
+ if not timer.isActive():
42
+ action()
43
+ timer.start(cooldown)
44
+
45
+ button.clicked.connect(handler)
46
+
47
+ def on_toggle(self, button, on_action, off_action=None):
48
+ button.setCheckable(True)
49
+
50
+ def handler(checked):
51
+ on_action() if checked else off_action and off_action()
52
+
53
+ button.toggled.connect(handler)
54
+
55
+ def on_click_once(self, button, action):
56
+ def wrapper():
57
+ action()
58
+ button.clicked.disconnect(wrapper)
59
+
60
+ button.clicked.connect(wrapper)
61
+
62
+ def on_hover(self, button, enter_action=None, leave_action=None):
63
+ class HoverFilter(QObject):
64
+ def eventFilter(self, obj, event):
65
+ if event.type() == QEvent.Type.Enter and enter_action:
66
+ enter_action()
67
+ elif event.type() == QEvent.Type.Leave and leave_action:
68
+ leave_action()
69
+ return False
70
+
71
+ filt = HoverFilter(button)
72
+ self._filters[button] = filt
73
+ button.installEventFilter(filt)
@@ -0,0 +1,64 @@
1
+ from PyQt6.QtCore import Qt
2
+ from PyQt6.QtGui import QShortcut, QKeySequence
3
+ KEY_MAP = {
4
+ # Arrows
5
+ "left": Qt.Key.Key_Left,
6
+ "right": Qt.Key.Key_Right,
7
+ "up": Qt.Key.Key_Up,
8
+ "down": Qt.Key.Key_Down,
9
+
10
+ # Actions
11
+ "space": Qt.Key.Key_Space,
12
+ "enter": Qt.Key.Key_Return,
13
+ "escape": Qt.Key.Key_Escape,
14
+ "tab": Qt.Key.Key_Tab,
15
+ "shift": Qt.Key.Key_Shift,
16
+ "ctrl": Qt.Key.Key_Control,
17
+ "alt": Qt.Key.Key_Alt,
18
+ }
19
+
20
+ # Letters
21
+ for c in "abcdefghijklmnopqrstuvwxyz":
22
+ KEY_MAP[c] = getattr(Qt.Key, f"Key_{c.upper()}")
23
+
24
+ class Input:
25
+ _pressed = set()
26
+ _just_pressed = set()
27
+ _just_released = set()
28
+
29
+ @classmethod
30
+ def input_update(cls):
31
+ cls._just_pressed.clear()
32
+ cls._just_released.clear()
33
+
34
+ @classmethod
35
+ def key_down(cls, key):
36
+ qt_key = KEY_MAP.get(key, key)
37
+ if qt_key not in cls._pressed:
38
+ cls._just_pressed.add(qt_key)
39
+ cls._pressed.add(qt_key)
40
+
41
+ @classmethod
42
+ def key_up(cls, key):
43
+ qt_key = KEY_MAP.get(key, key)
44
+ if qt_key in cls._pressed:
45
+ cls._just_released.add(qt_key)
46
+ cls._pressed.discard(qt_key)
47
+
48
+ # === Public API ===
49
+ @classmethod
50
+ def is_pressed(cls, key):
51
+ return KEY_MAP[key] in cls._pressed
52
+
53
+ @classmethod
54
+ def is_just_pressed(cls, key):
55
+ return KEY_MAP[key] in cls._just_pressed
56
+
57
+ @classmethod
58
+ def is_released(cls, key):
59
+ return KEY_MAP[key] in cls._just_released
60
+
61
+ class VShortcut(QShortcut):
62
+ def __init__(self, key, parent, callback):
63
+ super().__init__(QKeySequence(key), parent)
64
+ self.activated.connect(callback)
@@ -0,0 +1,142 @@
1
+ from PyQt6.QtWidgets import QPushButton, QLineEdit
2
+ from PyQt6.QtGui import QFont
3
+ from PyQt6.QtWidgets import QPushButton
4
+ from PyQt6.QtGui import QCursor
5
+ from PyQt6.QtCore import Qt
6
+ from PyQt6.QtWidgets import QLabel
7
+
8
+ class LegacyButton(QPushButton):
9
+ def __init__(
10
+ self,
11
+ text="Button",
12
+ width=120,
13
+ height=40,
14
+ text_color="white",
15
+ border_color="#FFFFFF",
16
+ border_width=2,
17
+ font_name="Arial",
18
+ font_weight=QFont.Weight.Bold,
19
+ parent=None
20
+ ):
21
+ super().__init__(text, parent)
22
+ # Store params
23
+ self.bg_color = '#000000'
24
+ self.hover_color = '#222222'
25
+ self.text_color = text_color
26
+ self.border_radius = 10
27
+ self.border_color = border_color
28
+ self.border_width = border_width
29
+ self.setFont(QFont(font_name, 12, font_weight))
30
+ self.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
31
+ self.setMinimumSize(width, height)
32
+ # Apply default style
33
+ self.setStyleSheet(self.default_style())
34
+
35
+ def enterEvent(self, event):
36
+ self.setStyleSheet(self.hover_style())
37
+ super().enterEvent(event)
38
+
39
+ def leaveEvent(self, event):
40
+ self.setStyleSheet(self.default_style())
41
+ super().leaveEvent(event)
42
+
43
+ def default_style(self):
44
+ return f"""
45
+ QPushButton {{
46
+ background-color: {self.bg_color};
47
+ color: {self.text_color};
48
+ border-radius: {self.border_radius}px;
49
+ border: {self.border_width}px solid {self.border_color};
50
+ }}
51
+ """
52
+
53
+ def hover_style(self):
54
+ return f"""
55
+ QPushButton {{
56
+ background-color: {self.hover_color};
57
+ color: {self.text_color};
58
+ border-radius: {self.border_radius}px;
59
+ border: {self.border_width}px solid {self.border_color};
60
+ }}
61
+ """
62
+ class Text(QLabel):
63
+ def __init__(
64
+ self,
65
+ text="Text",
66
+ font_size=14,
67
+ text_color="#FFFFFF",
68
+ bg_color=None,
69
+ padding=8,
70
+ border_radius=8,
71
+ parent=None
72
+ ):
73
+ super().__init__(text, parent)
74
+ self.setFont(QFont('Arial', font_size, QFont.Weight.Normal))
75
+ self.setAlignment(QFont.Weight.Normal)
76
+ bg = "transparent" if bg_color is None else bg_color
77
+ self.setStyleSheet(f"""
78
+ QLabel {{
79
+ color: {text_color};
80
+ background-color: {bg};
81
+ padding: {padding}px;
82
+ border-radius: {border_radius}px;
83
+ }}
84
+ """)
85
+
86
+ def set_text(self, text):
87
+ self.setText(text)
88
+
89
+ def set_color(self, color):
90
+ self.setStyleSheet(self.styleSheet() + f"color: {color};")
91
+
92
+ class InputField(QLineEdit):
93
+ def __init__(
94
+ self,
95
+ placeholder="Enter text...",
96
+ width=240,
97
+ height=36,
98
+ font_size=12,
99
+ focus_color="#00E5FF",
100
+ border_radius=8,
101
+ padding=8,
102
+ parent=None
103
+ ):
104
+ super().__init__(parent)
105
+ self.setPlaceholderText(placeholder)
106
+ self.setFont(QFont('Arial', font_size))
107
+ self.setMinimumSize(width, height)
108
+ self.text_color = "#FFFFFF"
109
+ self.bg_color = '#1E1E1E'
110
+ self.border_color = '#555555'
111
+ self.focus_color = focus_color
112
+ self.border_radius = border_radius
113
+ self.padding = padding
114
+ self.apply_style(focused=False)
115
+
116
+ def apply_style(self, focused=False):
117
+ border = self.focus_color if focused else self.border_color
118
+ self.setStyleSheet(f"""
119
+ QLineEdit {{
120
+ color: {self.text_color};
121
+ background-color: {self.bg_color};
122
+ border: 2px solid {border};
123
+ border-radius: {self.border_radius}px;
124
+ padding: {self.padding}px;
125
+ }}
126
+ QLineEdit::placeholder {{
127
+ color: #888888;
128
+ }}
129
+ """)
130
+
131
+ def focusInEvent(self, event):
132
+ self.apply_style(focused=True)
133
+ super().focusInEvent(event)
134
+
135
+ def focusOutEvent(self, event):
136
+ self.apply_style(focused=False)
137
+ super().focusOutEvent(event)
138
+
139
+ def get_value(self):
140
+ return self.text()
141
+ def set_value(self, value):
142
+ self.setText(value)