Exemple #1
0
class Window:
    """Application window.
    """
    def __init__(self):
        self._qt_window = QMainWindow()
        self._qt_central_widget = QWidget()
        self._qt_window.setCentralWidget(self._qt_central_widget)
        self._qt_central_widget.setLayout(QHBoxLayout())
        self._qt_window.statusBar().showMessage('Ready')

        self._viewers = []

    @property
    def viewers(self):
        """list of Viewer: Contained viewers.
        """
        return self._viewers

    def add_viewer(self):
        """Adds a viewer to the containing layout.

        Returns
        -------
        viewer : Viewer
            Viewer object.
        """
        viewer = Viewer(self)
        self.viewers.append(viewer)
        self._qt_central_widget.layout().addLayout(viewer.controls._qt)
        self._qt_central_widget.layout().addWidget(viewer._qt)
        self._qt_central_widget.layout().addWidget(viewer.layers._qt)
        return viewer

    def resize(self, *args):
        self._qt_window.resize(*args)

    def show(self):
        self.resize(self._qt_window.layout().sizeHint())
        self._qt_window.show()
        self._qt_window.raise_()
Exemple #2
0
    # button = QPushButton()
    # button.move(0, 0)
    # button.resize(100, 100)
    # window.layout().addWidget(button)


app = QApplication([])

window = QMainWindow()
window.resize(1000, 1000)

button=QPushButton()
button.move(100,0)
button.resize(100,100)
window.layout().addWidget(button)

signal = Signal()
signal.connect(lambda data: signal_function(data))


window.show()

executor = ThreadPoolExecutor(2)
executor.submit(lambda:infinite_server())

app.exec()



Exemple #3
0
bg_new = 'background-color: rgb(%d,%d,%d);' % (random.randint(
    1, 255), random.randint(1, 255), random.randint(1, 255))

window.setStyleSheet(bg_new)
window.resize(900, 600)

title = QtWidgets.QLabel(window)
title.setStyleSheet("background-color: rgba(0,0,0,0%)")
IMG_TITLE = [QPixmap("static/img/title")]
change_img(title, IMG_TITLE, 0, 330, 430)
title.resize(450, 300)
title.move(window.width() // 2 - title.width() // 2,
           window.height() // 2 - 272)
title.move(-123, window.height() // 2 - 272)
title.LableOpacity(0.2)
window.layout().addWidget(title)
window.title = title
window.setWindowOpacity(0.9)

hand = QtWidgets.QLabel(window)
IMG_HANDS = [QPixmap("static/img/hand0.png"), QPixmap("static/img/hand1.png")]
bg_new = 'background-color: rgb(%d,%d,%d);' % (random.randint(
    1, 255), random.randint(1, 255), random.randint(1, 255))
hand.setStyleSheet("background-color: rgba(0,0,0,0%)")
# hand.setStyleSheet(bg_new)
hand.resize(100, 90)

hand.move(window.width() // 2 - hand.width() // 2 + 10,
          window.height() // 2 + 150)
window.layout().addWidget(hand)
window.hand = hand
Exemple #4
0
class Window:
    """Application window that contains the menu bar and viewers.

    Parameters
    ----------
    viewer : Viewer
        Contained viewer.

    Attributes
    ----------
    viewer : Viewer
        Contained viewer.
    """
    def __init__(self, viewer, show=True):
        self._qt_window = QMainWindow()
        self._qt_center = QWidget()
        self._qt_window.setCentralWidget(self._qt_center)
        self._qt_center.setLayout(QHBoxLayout())
        self._statusBar = self._qt_window.statusBar()
        self._statusBar.showMessage('Ready')

        self._help = QLabel('')
        self._statusBar.addPermanentWidget(self._help)

        self.viewer = viewer
        self._qt_center.layout().addWidget(self.viewer._qt)

        self.viewer.statusChanged.connect(self._statusChanged)
        self.viewer.helpChanged.connect(self._helpChanged)

        if show:
            self.show()

    def resize(self, width, height):
        """Resize the window.

        Parameters
        ----------
        width : int
            Width in logical pixels.
        height : int
            Height in logical pixels.
        """
        self._qt_window.resize(width, height)

    def show(self):
        """Resize, show, and bring forward the window.
        """
        self._qt_window.resize(self._qt_window.layout().sizeHint())
        self._qt_window.show()
        self._qt_window.raise_()

    def _statusChanged(self, message):
        """Update status bar.
        """
        self._statusBar.showMessage(message)

    def _helpChanged(self, message):
        """Update help message on status bar.
        """
        self._help.setText(message)
Exemple #5
0
hero_img_names = ['chicken_rd.png', 'chicken_up.png', 'chicken_lf.png', 'chicken_dw.png']
HERO_IMG = [QPixmap("static/img/" + img_name) for img_name in hero_img_names]

tree_img_names = ['small.png', 'medium.png', 'large.png']
TREE_IMG = [QPixmap("static/img/tree-" + img_name) for img_name in tree_img_names]

car_img_names = ['p_l.png', 'p_r.png', 'y_l.png', 'y_r.png']
CAR_IMG = [QPixmap("static/img/car_" + img_name) for img_name in car_img_names]

base_window = HeroWindow()
base_window.resize(900, 600)

base_window.setStyleSheet("background-color:  #123E73")
base_window.layout().addWidget(window)

pole = drow()
pole.resize(900, 600)
window.layout().addWidget(pole)

filling_the_window(window)
make_hero(window, base_window)

base_window.hero.timer = QTimer()
timer = base_window.hero.timer
timer.timeout.connect(lambda: move_hero(window.hero.direction))
timer.start(230)

base_window.show()
root.exec()
Exemple #6
0
        self.coords.append(coord)
        print(coord)
        self.repaint()


if __name__ == "__main__":
    app = QApplication([])

    window = QMainWindow()
    window.resize(1000, 1000)

    pole = Pole()
    pole.setFixedSize(settings.w * settings.size + 11,
                      settings.h * settings.size + 11)
    pole.move(settings.a, settings.b)
    window.layout().addWidget(pole)

    pole2 = Pole()
    pole2.setFixedSize(settings.w * settings.size + 11,
                       settings.h * settings.size + 11)
    pole2.move(settings.a + settings.w * settings.size + 4 * settings.size,
               settings.b)
    window.layout().addWidget(pole2)

    for i in range(settings.ship_1):
        ship = Ship(1, VERTICAL)
        ship.move(settings.x1, settings.y1)
        ship.setStyleSheet("background-color: #F4FA58")
        settings.x1 += settings.size + 10
        window.layout().addWidget(ship)
Exemple #7
0
        sock.sendall(text.encode("utf-8"))
        sock.close()
    except Exception as e:
        print("Artem is not available")


app = QApplication([])

window = QMainWindow()
window.resize(1000, 1000)

textField = QTextEdit()
textField.resize(400, 800)
textField.move(0, 0)
window.layout().addWidget(textField)

button = QPushButton()
button.move(350, 810)
button.resize(100, 100)
button.setText("Artemy")
window.layout().addWidget(button)
button.clicked.connect(lambda: send_to_Artemy(textField2))

button = QPushButton()
button.move(250, 810)
button.resize(100, 100)
button.setText("Artem")
window.layout().addWidget(button)
button.clicked.connect(lambda: send_to_Artem(textField2))
Exemple #8
0
class Window:
    """Application window that contains the menu bar and viewers.

    Attributes
    ----------
    viewers : list of Viewer
        Contained viewers.
    """
    def __init__(self):
        self._qt_window = QMainWindow()
        self._qt_central_widget = QWidget()
        self._qt_window.setCentralWidget(self._qt_central_widget)
        self._qt_central_widget.setLayout(QHBoxLayout())
        self._qt_window.statusBar().showMessage('Ready')

        self._viewers = []

    @property
    def viewers(self):
        """list of Viewer: Contained viewers.
        """
        return self._viewers

    def add_viewer(self):
        """Add a viewer to the containing layout.

        Returns
        -------
        viewer : Viewer
            Viewer object.
        """
        viewer = Viewer(self)
        self.viewers.append(viewer)

        # To split vertical sliders, viewer and layerlist, minimumsizes given for demo purposes/NOT FINAL
        horizontalSplitter = QSplitter(Qt.Horizontal)
        viewer.controls._qt.setMinimumSize(QSize(40, 40))
        horizontalSplitter.addWidget(viewer.controls._qt)
        viewer._qt.setMinimumSize(QSize(100, 100))
        horizontalSplitter.addWidget(viewer._qt)
        viewer.layers._qt.setMinimumSize(QSize(250, 250))
        horizontalSplitter.addWidget(viewer.layers._qt)

        self._qt_central_widget.layout().addWidget(horizontalSplitter)
        return viewer

    def resize(self, width, height):
        """Resize the window.

        Parameters
        ----------
        width : int
            Width in logical pixels.
        height : int
            Height in logical pixels.
        """
        self._qt_window.resize(width, height)

    def show(self):
        """Resize, show, and bring forward the window.
        """
        self._qt_window.resize(self._qt_window.layout().sizeHint())
        self._qt_window.show()
        self._qt_window.raise_()
Exemple #9
0
root = QApplication([])
window = QMainWindow()
bg_new = 'background-color: rgb(%d,%d,%d);' % (random.randint(
    1, 255), random.randint(1, 255), random.randint(1, 255))

window.setStyleSheet(bg_new)
window.resize(900, 600)
#
# quit = QAction("Quit", window)
# quit.triggered.connect(lambda: make_w())

clock = QtWidgets.QLabel(window)
clock.setFont(QFont("setItalic", 20))
clock.setText('Label Example')
bg_new = 'background-color: rgb(%d,%d,%d);' % (random.randint(
    1, 255), random.randint(1, 255), random.randint(1, 255))
clock.setStyleSheet(bg_new)
clock.move(0, 0)
window.layout().addWidget(clock)
window.clock = clock

clock.timer = QTimer()
timer = window.clock.timer
starting_cordinate_hero = [window.clock.y(), window.clock.x()]
timer.timeout.connect(
    lambda: jump_to_down(starting_cordinate_hero, window.clock))
timer.start(30)

window.show()
root.exec()