Oct-27-2020, 09:40 PM
import json import math import os import PyQt5 from PyQt5.QtWidgets import * from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5 import QtWidgets import sys from importlib import import_module class Window(QWidget): def __init__(self): super().__init__() self.setWindowTitle("Grandier Calcutron") self.setWindowIcon(QIcon('icon.ico')) self.setGeometry(0, 0, 2000, 992) self.Welcome_Message() def Welcome_Message(self): global __Format__ Y = 10 X = 100 Scale_X = 120 Scale_Y = 30 welcome_message = QLabel("Welcome to the Grandier Calcutron!", self) welcome_message.setFont(QFont("Arial",16)) welcome_message.move(700, 300) tutorial_message_1 = QLabel("Import a deck to begin!\nFormatting examples are in the sample files.", self) tutorial_message_1.setFont(QFont("Arial",16)) tutorial_message_1.setAlignment(Qt.AlignCenter) tutorial_message_1.move(660, 340) Import_Deck = QPushButton(self) Import_Sym = QPixmap("symbols/import_sym") Import_Sym = QIcon(Import_Sym) Import_Deck.setIcon(Import_Sym) Import_Deck.clicked.connect(self.import_click) Import_Deck.clicked.connect(welcome_message.hide) Import_Deck.clicked.connect(tutorial_message_1.hide) Import_Deck.clicked.connect(Import_Deck.hide) Import_Deck.move(10, 10) Import_Deck.resize(100, 100) stats_button = QPushButton("Stats", self) stats_button.move(250, Y) stats_button.resize(120, 30) formats = ["Commander", "Oath Breaker", "Standard", "Free-Form", "Artisan", "Prismatic"] self.combo = QComboBox(self) for i in formats: self.combo.addItem(i) self.combo.move(370,Y+1) self.combo.resize(120, 28) __Format__ = self.combo.currentText() def display_color_event(self): X = 30 Y = 10 color_icon = QPixmap("symbols/C.png") color_icon_label = QLabel(self) new_color_icon = color_icon.scaled(100, 100, Qt.KeepAspectRatio, Qt.FastTransformation) color_icon_label.setPixmap(new_color_icon) color_icon_label.move(X, Y) color_icon_label.show() def import_click(self): self.openFileNameDialog() ext = os.path.splitext(deckFile)[-1].lower() if ext == ".cmdr": fmtda.commander.decklist_import(deckFile) self.decklist_display(formatword="commander") elif ext == ".oath": fmtda.oathbreaker.decklist_import(deckFile) self.decklist_display(formatword="oath-breaker") elif ext == ".stand": fmtda.standard.decklist_import(deckFile) self.decklist_display() elif ext == ".free": fmtda.free_form.decklist_import(deckFile) self.decklist_display() elif ext == ".arti": fmtda.artisan.decklist_import(deckFile) self.decklist_display() elif ext == ".pris": fmtda.prismatic.decklist_import(deckFile) self.decklist_display() self.display_color_event() def decklist_display(self, formatword="nil"): lis = fmtda.base_decklist commanderlis = fmtda.commanders Y_BASE = 120 X_BASE = 20 X = 20 X2 = 18 Y = 120 Y2 = 100 for num, card in lis: if card in commanderlis: label = QLabel(f"{card} is your {formatword}", self) print(f"{card} is your {formatword}") else: label = QLabel(f"{num}x {card}", self) pixmap = QPixmap("UI/namebox.png") image = QLabel(self) pixmap = pixmap.scaled(200, 30, Qt.KeepAspectRatio, Qt.FastTransformation) image.setPixmap(pixmap) image.move(X2, Y2) image.show label.setFont(QFont("Arial",12)) label.move(X, Y) label.show() Y = Y+26 Y2 = Y2+30 if Y > (Y_BASE)+26*31: Y = Y_BASE X = X+333 Y = Y_BASE X = X_BASE for card in commanderlis: label = QLabel(f"{card} is your {formatword}", self) print(f"{card} is your {formatword}") label.setFont(QFont("Arial",12)) label.move(X+120, Y-30) label.show() Y = Y+26 Y2 = Y2+30 if Y > (Y_BASE)+26*31: Y = Y_BASE X = X+333 def openFileNameDialog(self): global deckFile deckfile = 0 options = QFileDialog.Options() options |= QFileDialog.DontUseNativeDialog fileName, _ = QFileDialog.getOpenFileName(self,"QFileDialog.getOpenFileName()", "","Commander files (*.cmdr);;Oath Breaker files (*.oath);;Standard files (*.stand);;Free Form files (*.free);;Artisan files (*.arti);;Prismatic files (*.pris)", options=options) deckFile = fileName app = QApplication(sys.argv) screen = Window() screen.show() sys.exit(app.exec_())This is my code, the issue with it is the button icon is far too small. I want it to be larger, (100px by 100px) and it needs to be all that's visible of the button.
I also want a menu bar and I cannot figure out how to implement that. I've tried just about everything on the first two pages of google. I also cannot use QtDesigner. Any help would be much appreciated!