def update(self, render=None): SelectionMenu.update(self, render) if self.isActive and self.isSelect: done = False for widgetList in self._widget: for child in widgetList: if isinstance(child, Active) and \ child.isActive and child is not self._currentActive: print("ok") self._currentActive = child done = True break if done: break if not self._currentActive: done = False for widgetList in self._widget: for child in widgetList: if isinstance(child, Active): self._currentActive = child done = True break if done: break self.disactiveOtherWidget()
def __init__(self, parent=None, rect=sf.Rectangle(),\ alignment = Position.Center, spacing=sf.Vector2(0, 0), \ autoDefineSize = True, select=False, active=False, \ alwaysUpdateSelection=True, alwaysUpdateActivation=True, \ permanentSelection=False, permanentActivation=False, \ changeRight = sf.Keyboard.RIGHT, changeLeft = sf.Keyboard.LEFT,\ changeTop = sf.Keyboard.UP, changeBottom = sf.Keyboard.DOWN): SelectionMenu.__init__(self,parent, rect, alignment, spacing, \ autoDefineSize, select, active, alwaysUpdateSelection, \ alwaysUpdateActivation, permanentSelection, permanentActivation, \ changeRight, changeLeft, changeTop, changeBottom) self._currentActive = None
def main(): app = QtWidgets.QApplication([]) window = QtWidgets.QWidget() window.showFullScreen() layout = QtWidgets.QGridLayout(window) menu = SelectionMenu(layout) layout.addWidget(QtWidgets.QLabel(), 0, 0) layout.addWidget(menu, 1, 0) layout.addWidget(QtWidgets.QLabel(), 2, 0) app.exec_() del app
progress2 = ProgressBar(window, sf.Rectangle(sf.Vector2(0, 200), sf.Vector2(100, 20))) progress3 = ProgressBar(window, sf.Rectangle(sf.Vector2(0, 300), sf.Vector2(100, 20))) progress4 = ProgressBar(window, sf.Rectangle(sf.Vector2(0, 400), sf.Vector2(100, 20))) progress5 = ProgressBar(window, sf.Rectangle(sf.Vector2(0, 430), sf.Vector2(100, 20))) label = Label(None, "Hello\nnop\n\n\ndon't\n\nfinish withing you !, have many many many many impro to doing ! You don't finish to listen me !", characterSize=20, font =sf.Font.from_file("DejaVuSans.ttf")) textArray = TextArray(window, label=label, alignment=Position.Center, cutStyle =Cut.Word, sizeX = 600) slide = Slide(window, rect=sf.Rectangle(sf.Vector2(300, 30), sf.Vector2(500, 20)), step=1, inStep=5, values=sf.Vector2(0, 50)) slide2 = Slide(window, rect=sf.Rectangle(sf.Vector2(100, 230), sf.Vector2(500, 20)), step=1, inStep=5, values=sf.Vector2(0, 50)) slide3 = Slide(window, rect=sf.Rectangle(sf.Vector2(100, 330), sf.Vector2(500, 20)), step=1, inStep=5, values=sf.Vector2(0, 50)) slide4 = Slide(window, rect=sf.Rectangle(sf.Vector2(100, 430), sf.Vector2(500, 20)), step=1, inStep=5, values=sf.Vector2(0, 50)) slide5 = Slide(window, rect=sf.Rectangle(sf.Vector2(100, 470), sf.Vector2(500, 20)), step=1, inStep=5, values=sf.Vector2(0, 50)) #frame = Frame(window, sf.Rectangle(sf.Vector2(10, 10), sf.Vector2(400, 300)), title="frame") layout = SelectionMenu(window, permanentActivation=True) layout.spacing = sf.Vector2(10, 10) box = CheckBox(window, sf.Rectangle(sf.Vector2(100, 100), sf.Vector2(50, 50))) box2 = CheckBox(None, sf.Rectangle(sf.Vector2(20, 20), sf.Vector2(50, 50))) box3 = CheckBox(None, sf.Rectangle(sf.Vector2(20, 20), sf.Vector2(50, 50))) box4 = CheckBox(None, sf.Rectangle(sf.Vector2(20, 20), sf.Vector2(100, 100))) box5 = CheckBox(None, sf.Rectangle(sf.Vector2(20, 20), sf.Vector2(100, 100))) layout.addWidget(box, sf.Vector2(1, 0), sf.Vector2(1, 1)) layout.addWidget(box2, sf.Vector2(1, 1), sf.Vector2(1, 1)) layout.addWidget(box3, sf.Vector2(0, 2), sf.Vector2(1, 1)) layout.addWidget(box4, sf.Vector2(2, 1), sf.Vector2(1, 1)) layout.addWidget(box5, sf.Vector2(1, 1), sf.Vector2(1, 1)) layout.posOrigin = Position.Center layout.pos = sf.Vector2(400, 300) layout.setAllActiveMouseKeyboard(sf.Keyboard.RETURN, sf.Mouse.LEFT) layout.canFocus = False