Skip to content

Commit

Permalink
Added FXPasswordLineEdit, fixed methods when subclassing FXWidgets
Browse files Browse the repository at this point in the history
  • Loading branch information
healkeiser committed Sep 4, 2024
1 parent 1c639af commit 3678324
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 165 deletions.
20 changes: 0 additions & 20 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,6 @@
"QT_API": "pyside2"
},
"git.ignoreLimitWarning": true,
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#4d4d4d",
"activityBar.background": "#4d4d4d",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#308f30",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#4d4d4d",
"statusBar.background": "#333333",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#4d4d4d",
"statusBarItem.remoteBackground": "#333333",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#333333",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#33333399",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#333333",
"cSpell.words": [
"fxdcc",
"fxgui",
Expand Down
108 changes: 104 additions & 4 deletions fxgui/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Built-in
import os

print(">>> ", os.getenv("QT_API"))

# Third-party
import qtawesome as qta
from qtpy.QtWidgets import *
Expand All @@ -20,6 +18,54 @@
_pixmap = os.path.join(os.path.dirname(__file__), "images", "splash.png")


def show_login_dialog():
class FXLoginDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)

self.setModal(True)
self.setWindowTitle("Login")
self.resize(500, 100)
main_layout = QVBoxLayout()
form_layout = QFormLayout()
form_layout.setLabelAlignment(Qt.AlignRight)

# Login
self.login_line_edit = QLineEdit()
self.login_line_edit.setPlaceholderText("Mail...")
form_layout.addRow("Login", self.login_line_edit)

# Password
self.password_line_edit = fxwidgets.FXPasswordLineEdit()
self.password_line_edit.line_edit.setPlaceholderText("Password...")
form_layout.addRow("Password", self.password_line_edit)

# Remember Me
self.remember_me_checkbox = QCheckBox("Remember Me")
form_layout.addRow("", self.remember_me_checkbox)

# Add form layout to main layout
main_layout.addLayout(form_layout)

# Buttons
button_box = QDialogButtonBox(
QDialogButtonBox.Cancel | QDialogButtonBox.Ok
)
button_box.button(QDialogButtonBox.Cancel).setText("Cancel")
button_box.button(QDialogButtonBox.Ok).setText("Login")

# Close on cancel
button_box.rejected.connect(self.reject)

main_layout.addWidget(button_box)
self.setLayout(main_layout)

_fix = QUiLoader() # XXX: This is a PySide6 bug
application = fxwidgets.FXApplication()
dialog = FXLoginDialog()
dialog.exec_()


def show_window_houdini():
"""An example FXMainWindow instance launched from inside Houdini."""

Expand Down Expand Up @@ -124,6 +170,58 @@ def show_window_alt():
application.exec_()


def subclass_window():
_fix = QUiLoader() # XXX: This is a PySide6 bug
application = fxwidgets.FXApplication()

class MyWidget(QWidget):
def __init__(self, parent=None):
super().__init__(parent)

self.add_layout()
self.add_buttons()

def add_layout(self):
"""Adds a vertical layout to the main layout of the widget."""

self.main_layout = QVBoxLayout()
self.setLayout(self.main_layout)

def add_buttons(self):
"""Adds buttons to the main layout of the widget."""

pulse_button = QPushButton("Pulse Button")
pulse_animation = qta.Pulse(pulse_button)
pulse_icon = qta.icon(
"fa.spinner", color="#b4b4b4", animation=pulse_animation
)
pulse_button.setIcon(pulse_icon)

spin_button = QPushButton("Spin Button")
spin_animation = qta.Spin(spin_button)
spin_icon = qta.icon(
"fa5s.spinner", color="#b4b4b4", animation=spin_animation
)
spin_button.setIcon(spin_icon)

self.main_layout.addWidget(pulse_button)
self.main_layout.addWidget(spin_button)
self.main_layout.addStretch()

class MyWindow(fxwidgets.FXMainWindow):
def __init__(self, parent=None):
super().__init__(parent)

self.toolbar.hide()
self.setCentralWidget(MyWidget(parent=self))
self.adjustSize()

window = MyWindow()
window.setWindowTitle("My Window")
window.show()
application.exec_()


def main(show_delayed: bool = False):
"""Main example function.
Expand Down Expand Up @@ -205,7 +303,7 @@ def main(show_delayed: bool = False):

style = window.style()
window.ui.button_critical.setIcon(
style.standardIcon(QStyle.SP_MediaVolumeMuted)
style.standardIcon(QStyle.SP_MessageBoxCritical)
)

# Set tooltips on the buttons
Expand Down Expand Up @@ -239,4 +337,6 @@ def restore_icon():
if __name__ == "__main__":
# main()
# show_window()
show_window_alt()
# show_window_alt()
# subclass_window()
show_login_dialog()
Loading

0 comments on commit 3678324

Please sign in to comment.