Further GUI Prototyping
This commit is contained in:
parent
68e9f57d22
commit
2b81329950
@ -1,8 +1,7 @@
|
|||||||
import sys
|
import sys
|
||||||
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton
|
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton, QTreeView
|
||||||
from PyQt5.Qt import QStandardItemModel, QStandardItem
|
from PyQt5.Qt import QStandardItemModel, QStandardItem
|
||||||
from PyQt5.QtGui import QIcon
|
from PyQt5.QtCore import pyqtSlot, QAbstractListModel
|
||||||
from PyQt5.QtCore import pyqtSlot
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import GlowstoneDust
|
import GlowstoneDust
|
||||||
@ -10,28 +9,53 @@ import GlowstoneDust
|
|||||||
|
|
||||||
class App(QMainWindow):
|
class App(QMainWindow):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, target_dir='.'):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.title = 'Project Glowstone: Block Edition'
|
self.title = 'Project Glowstone: Block Edition'
|
||||||
self.left = 300
|
self.left = 300
|
||||||
self.top = 300
|
self.top = 300
|
||||||
self.width = 640
|
self.width = 640
|
||||||
self.height = 480
|
self.height = 480
|
||||||
self.initUI()
|
self.target_dir = target_dir
|
||||||
|
self.init_ui()
|
||||||
|
|
||||||
def initUI(self):
|
def init_ui(self):
|
||||||
self.setWindowTitle(self.title)
|
self.setWindowTitle(self.title)
|
||||||
self.setGeometry(self.left, self.top, self.width, self.height)
|
self.setGeometry(self.left, self.top, self.width, self.height)
|
||||||
|
|
||||||
button = QPushButton('Button Label Go Here', self)
|
self.treeView = QTreeView()
|
||||||
button.setToolTip('Example Button')
|
self.treeView.setHeaderHidden(True)
|
||||||
button.setGeometry(100, 70, 200, 80)
|
|
||||||
# button.move(100, 70)
|
self.update_modlist(list(GlowstoneDust.get_modpack_info(self.target_dir)))
|
||||||
button.clicked.connect(self.make_tree)
|
|
||||||
|
|
||||||
self.statusBar().showMessage('Message')
|
self.statusBar().showMessage('Message')
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
def update_modlist(self, modlist=None):
|
||||||
|
self.treeModel = QStandardItemModel()
|
||||||
|
self.rootNode = self.treeModel.invisibleRootItem()
|
||||||
|
|
||||||
|
self.modlist = modlist or []
|
||||||
|
print(json.dumps(self.modlist, indent=4))
|
||||||
|
|
||||||
|
mc = QStandardItem('Minecraft')
|
||||||
|
mc.setEditable(False)
|
||||||
|
self.rootNode.appendRow(mc)
|
||||||
|
|
||||||
|
for mod in self.modlist:
|
||||||
|
mod_row = QStandardItem(mod['modid'])
|
||||||
|
for dependant_mod in mod.get('dependencies', []):
|
||||||
|
if dependant_mod is dict:
|
||||||
|
mod_row.appendRow(QStandardItem(dependant_mod.get('modid')))
|
||||||
|
else:
|
||||||
|
mod_row.appendRow(QStandardItem(dependant_mod))
|
||||||
|
mc.appendRow(mod_row)
|
||||||
|
|
||||||
|
self.treeView.setModel(self.treeModel)
|
||||||
|
self.treeView.expandAll()
|
||||||
|
self.setCentralWidget(self.treeView)
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def on_click(self):
|
def on_click(self):
|
||||||
print('PyQt5 button click')
|
print('PyQt5 button click')
|
||||||
@ -45,5 +69,5 @@ class App(QMainWindow):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
ex = App()
|
ex = App(target_dir=r"C:\Users\VY Canis Majoris\AppData\Roaming\.moddedminecraft\1.12\1.12.2\Sinkhole\mods")
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user