def change_next(self, pos): if not pos: self.hide() if isinstance(self, IF): if self.extra: self.extra.hide() del self.extra del self else: if not isinstance(self, IF): self.move(pos[0], pos[1]) else: self.move(*adjust(((pos[2] - 0.5) * 175 + first_next[0], pos[1]))) if self.extra: self.extra.move(*adjust(((pos[2] + 0.5) * 175 + first_next[0], pos[1]))) else: a = ELSE(self.parent) a.move(*adjust(((pos[2] + 0.5) * 175 + first_next[0], pos[1]))) a.show() a.click() a.setEnabled(False) self.extra = a self.set = True self.col = pos[2] if not isinstance(self, IF) else pos[2] - 0.5 self.row = pos[3]
def __init__(self, parent=None): super().__init__(parent) self.setGeometry(0, 30, SCREEN_WIDTH, SCREEN_HEIGHT) self.setFixedSize(SCREEN_WIDTH, SCREEN_HEIGHT) self.label = QLabel(self) self.label.setGeometry(*adjust((250, 35, SCREEN_WIDTH - 250, SCREEN_HEIGHT - 35))) self.label.setStyleSheet("background-color: rgba(0,0,0,20%)") self.current_window = 0 self.current_size = 0 self.layout = Layout(self) a = Tab(self, self.current_size) self.tabs = {0: a} self.windows = {0: self.layout} self.boton_addTab = QPushButton('+', self) self.boton_addTab.setGeometry(*adjust((350, 0, 35, 35))) self.boton_addTab.clicked.connect(self.new_tab) self.global_var = {'X': 0, 'Y': 100, 'Z': 5, 'speed': 3000, 'hp': 150} self.show()
def __init__(self, parent): super().__init__(parent) self.setGeometry(*adjust((0, 0, SCREEN_WIDTH, SCREEN_HEIGHT))) self.initial_next = Next(self) self.if_creator = IF(self, True) self.while_creator = WHILE(self, True) self.set_creator = SET(self, True) self.colrows = {(0, 0): self.initial_next} self.local_var = {'i': 0} self.execute_button = QPushButton('Execute code', self) self.execute_button.setFont(bigfont) self.execute_button.setGeometry(*adjust((SCREEN_WIDTH - 250, SCREEN_HEIGHT - 100, 150, 60))) self.execute_button.setStyleSheet( 'background-color: rgba(255, 255, 255, 80%)') self.see_global = QPushButton('GLOBAL VARIABLES', self) self.see_global.setFont(bigfont) self.see_global.move(*adjust((50, 350))) self.see_global.clicked.connect(self.see_global_variables) self.show()
def __init__(self, variables, type, parent=None): super().__init__(parent) self.layout = QScrollArea(self) self.layout.setGeometry(*adjust((0, 0, 600, 600))) self.setGeometry(*adjust((350, 150, 600, 600))) self.variables = variables i = 0 self.edits = [] self.apply_button = QPushButton('Apply changes', self.layout) self.apply_button.setGeometry(*adjust((400, 500, 100, 50))) self.apply_button.setFont(newfont) self.apply_button.clicked.connect(self.apply_changes) for var in variables.keys(): a = QLabel(var, self.layout) a.move(*adjust((50, 30 + i * 50))) a.setFont(newfont) b = QLineEdit(str(variables[var]), self.layout) b.move(*adjust((140, 30 + i * 50))) b.setFont(newfont) i += 1 self.edits.append(b) a.show() b.show() self.show()
def __init__(self, parent, creador=False): super().__init__(parent, creador) self.setStyleSheet(else_yeah) self.setGeometry(*adjust((else_creator[0], else_creator[1], 150, 50))) self.layer = QGroupBox(self) self.layer.setGeometry(*adjust((0, 0, 150, 50))) self.text = QLabel("Else", self.layer) self.text.setFont(newfont) self.text.move(*adjust((60, 18)))
def mouseDoubleClickEvent(self, event): if not self.editando: self.editando = True self.edit = QLineEdit(self.name, self.parent()) self.edit.setGeometry(*adjust((self.size * 105 + 250, 0, 100, 35))) self.edit.show() self.edit.setFocus(True)
def __init__(self, parent, col=2, row=0): super().__init__(parent) self.setFixedSize(150, 50) self.setText("drop here to add") self.setFont(newfont) self.setEnabled(False) self.col = col self.row = row self._used = False self.move(*adjust((first_next[0] + 175 * col, first_next[1] + 65 * row)))
def __init__(self, parent, creador=False): super().__init__(parent, creador) self.setStyleSheet(set_yeah) self.setGeometry(*adjust((set_creator[0], set_creator[1], 150, 50))) self.layer = QGroupBox(self) self.layer.setGeometry(*adjust((0, 0, 150, 50))) self.text = QLabel("Set", self.layer) self.text.setFont(newfont) self.text.move(*adjust((5, 18))) self.edit1 = QLineEdit("X", self.layer) self.edit1.setFont(newfont) self.edit1.setGeometry(*adjust((30, 10, 40, 30))) self.text2 = QLabel("to", self) self.text2.setFont(newfont) self.text2.move(*adjust((75, 18))) self.edit2 = QLineEdit("0", self.layer) self.edit2.setFont(newfont) self.edit2.setGeometry(*adjust((100, 10, 40, 30)))
def __init__(self, parent, creador=False): super().__init__(parent, creador) signos = ['<', '>', '==', '!=', '>=', '<='] self.setStyleSheet(while_yeah) self.setGeometry(*adjust((while_creator[0], while_creator[1], 150, 50))) self.layer = QGroupBox(self) self.layer.setGeometry(*adjust((0, 0, 150, 50))) self.text = QLabel("while", self.layer) self.text.setFont(newfont) self.text.move(*adjust((5, 18))) self.edit1 = QLineEdit("X", self.layer) self.edit1.setFont(newfont) self.edit1.setGeometry(*adjust((40, 10, 35, 30))) self.signos = QComboBox(self.layer) for i in signos: self.signos.addItem(i) self.signos.setGeometry(*adjust((75, 10, 35, 30))) self.edit2 = QLineEdit("0", self.layer) self.edit2.setFont(newfont) self.edit2.setGeometry(*adjust((110, 10, 35, 30)))
def __init__(self, parent, size): super().__init__(parent) self.setGeometry(*adjust((size * 105 + 250, 0, 100, 35))) self.setStyleSheet("background-color: rgba(0,0,0,20%)") self.name = "New tab" self.size = size self.setText(" " + self.name) self.setFont(newfont) self.show() self.id = Tab.id Tab.id += 1 self._focused = True self.editando = False
def new_tab(self): self.windows[self.current_window].hide() self.layout = Layout(self) self.tabs[self.current_window].focused = False self.current_size += 1 self.current_window = self.current_size a = Tab(self, self.current_size) self.tabs[self.current_size] = a self.windows[self.current_window] = self.layout self.mousePressEvent("") self.boton_addTab.move(*adjust((350 + 105 * self.current_size, 0))) for i in self.tabs.values(): i.raise_() self.boton_addTab.raise_()
from PyQt5.QtCore import QTimer, Qt, QObject, QSize from PyQt5.QtWidgets import QProgressBar, QWidget, QLabel, QPushButton, \ QLineEdit, QGroupBox, QComboBox, QScrollArea from PyQt5.QtGui import QImage, QPalette, QBrush, QIcon, QPixmap, QFont import time from constantes import SCREEN_HEIGHT, SCREEN_WIDTH, else_creator, if_creator,\ set_creator, while_creator, first_next, adjust newfont = QFont("Copperplate Gothic Light", adjust([7])) bigfont = QFont("Copperplate Gothic Light", adjust([12])) if_yeah = """ QPushButton{ background-color: rgb(100,255,100,70%); border-width: 1px; } QPushButton::pressed { background-color: rgb(0, 0, 0,75%); }""" while_yeah = """ QPushButton{ background-color: rgb(255,100,100,70%); border-width: 1px; } QPushButton::pressed { background-color: rgb(0, 0, 0,75%); }"""