-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.py
More file actions
67 lines (48 loc) · 1.9 KB
/
mainwindow.py
File metadata and controls
67 lines (48 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# System Imports
import os
import sys
# Third Party Imports
from qtpy.QtWidgets import *
from qtpy.QtGui import *
from qtpy.QtCore import *
# Local Imports
from sharedtoolbox import style, configs
from sharedtoolbox.widgets.base import *
from sharedtoolbox.widgets import mainwidget
# ______________________________________________________________________________________________________________________
def launch():
"""Launch the SharedToolbox"""
app = QApplication.instance() or QApplication(sys.argv)
app.setStyle('Fusion')
app.setFont(QFont(style.FONT))
window = MainWindow()
window.setObjectName('sharedtoolbox')
window.show()
sys.exit(app.exec())
def launch_maya():
from shiboken2 import wrapInstance
import maya.OpenMayaUI as omui
ptr = omui.MQtUtil.mainWindow()
maya_main_window = wrapInstance(int(ptr), QWidget)
window = MainWindow(parent=maya_main_window)
window.setWindowFlags(Qt.Window)
window.setObjectName('sharedtoolbox')
window.show()
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.setStyleSheet(style.get_stylesheet())
self.setWindowTitle("Shared Toolbox")
self.resize(*configs.Prefs.main_window_size)
self.setMinimumSize(QSize(500, 300))
# Set the central widget of the Window.
self.main_widget = mainwidget.MainWidget(parent=self)
self.setCentralWidget(self.main_widget)
def closeEvent(self, event):
self._exit_handler()
super().closeEvent(event)
def _exit_handler(self):
"""Triggered on app quit"""
self.main_widget._exit_handler()
configs.Prefs.set_pref_data('main_window_size', (self.width(), self.height()))
# ______________________________________________________________________________________________________________________