Exemple #1
0
    def _setup_view(self) -> None:
        """
        Set up components of the GUI
        """
        self._navigator = Navigator(self._master,
                                    self.handle_move_callback,
                                    self.handle_jump_callback,
                                    bg=self._bg)
        self._navigator.pack(side=tk.TOP)

        frame = tk.Frame(self._master, bg=self._bg)
        frame.pack(side=tk.TOP)

        self._classifier = Classifier(frame,
                                      self.handle_select_callback,
                                      bg=self._bg)
        self._classifier.pack(side=tk.LEFT)

        self._preview = Preview(frame,
                                PREVIEW_WIDTH,
                                PREVIEW_HEIGHT,
                                callback=self._handle_preview_click)
        self._preview.pack(side=tk.LEFT)

        self._master.config(bg=self._bg)
        self._master.title("poprev")
        self._master.protocol("WM_DELETE_WINDOW", self._exit)
Exemple #2
0
    def __init__(self,
                 master,
                 callback: Callable[[int], None],
                 bg: str = "#ffffff"):
        """
        Initialise this Classifier
        :param master: parent container of this Classifier
        :param callback: function to call when the ColourSelector sub-component
        of this Classifier is clicked
        :param bg: the background colour of this Classifier
        """
        super().__init__(master, bg=bg, padx=5)

        self._callback = callback

        self._preview = Preview(self, REF_CANVAS_WIDTH, REF_CANVAS_HEIGHT)
        self._preview.pack(side=tk.TOP)

        self._selector = ColourSelector(
            self, ["#000000", "#555555", "#aaaaaa", "#ffffff"],
            ["#ffffff", "#aaaaaa", "#555555", "#000000"],
            self._callback,
            bg=bg)
        self._selector.pack(side=tk.TOP)

        self._img = None
Exemple #3
0
    def __init__(self, element, composition, timeline):
        goocanvas.Group.__init__(self)
        View.__init__(self)
        Zoomable.__init__(self)

        self.element = element
        self.comp = composition
        self.timeline = timeline

        self.bg = goocanvas.Rect(height=self.__HEIGHT__,
                                 fill_color_rgba=self.__NORMAL__,
                                 line_width=0)

        self.content = Preview(self.element)
        self.name = goocanvas.Text(x=10,
                                   text=os.path.basename(
                                       unquote(element.factory.name)),
                                   font="Sans 9",
                                   fill_color_rgba=0x000000FF,
                                   alignment=pango.ALIGN_LEFT)

        self.start_handle = StartHandle(element,
                                        timeline,
                                        height=self.__HEIGHT__)
        self.end_handle = EndHandle(element, timeline, height=self.__HEIGHT__)

        for thing in (self.bg, self.content, self.start_handle,
                      self.end_handle, self.name):
            self.add_child(thing)

        if element:
            self.zoomChanged()
        self.normal()
Exemple #4
0
    def setup_app(self):
        self.setupActions()
        splitter = QtGui.QSplitter(QtCore.Qt.Horizontal)
        self.tree = Tree()
        self.editor = Editor()

        self.tab_widget = QtGui.QTabWidget()
        self.preview = Preview()
        self.pdf_pane = PDFPane()
        self.tab_widget.addTab(self.preview, "HTML")
        self.tab_widget.addTab(self.pdf_pane, "PDF")

        self.file_path = None
        self.output_html_path = None

        self.setCentralWidget(splitter)
        splitter.addWidget(self.tree)
        splitter.addWidget(self.editor)

        splitter.addWidget(self.tab_widget)

        self.setWindowTitle("Sphinx Docs Editor")
        self.createMenus()
        self.createToolBars()
        self.showMaximized()
Exemple #5
0
 def spawn_shape(self):
     # new_shape = random.choice([F, L, Z, I, O])()
     self._shapes.append(self.next_shape)
     self.cur_shape = self.next_shape
     self.can_turbo = False
     self.next_shape = random.choice([F, L, Z, I, O])()
     self.preview = Preview(self.next_shape)
Exemple #6
0
    def createDockWidgets(self):

        # Palette widget
        self.palette = QtWidgets.QDockWidget(
            self.context.getText("dock_widgets", "palette"), self)
        self.palette.setAllowedAreas(Qt.RightDockWidgetArea)
        self.palette.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures)

        paletteWidget = Palette(self.context, self.signals)

        self.palette.setWidget(paletteWidget)
        self.palette.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                   QtWidgets.QSizePolicy.Minimum)

        self.addDockWidget(Qt.RightDockWidgetArea, self.palette)

        # Tool Properties widget
        self.toolProperties = ToolProperties(
            self.context.getText("dock_widgets", "tool_properties"),
            self.context, self.signals)
        self.addDockWidget(Qt.RightDockWidgetArea, self.toolProperties)
        self.toolProperties.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                          QtWidgets.QSizePolicy.Expanding)

        # Preview
        self.preview = Preview(self.context.getText("dock_widgets", "preview"),
                               self.context, self.signals, self)
        self.addDockWidget(Qt.RightDockWidgetArea, self.preview)
Exemple #7
0
    def __init__(self):
        # init pygame components
        pygame.init()
        pygame.display.set_caption(GAME_TITLE)
        self._screen = pygame.display.set_mode(SCREEN_RESOLUTION)
        self._background = pygame.Surface(self._screen.get_size()).convert()
        self._background.fill(colors.WHITE)
        self._font = pygame.font.SysFont(None, 24)
        self._set_message("Press PAUSE key to start!", colors.GREEN)

        # init game components
        rect_pixel_length = 20
        self._field = GameField(self._screen, GRID_COLUMNS, GRID_ROWS,
                                rect_pixel_length)
        self._preview = Preview(self._screen, SCREEN_RESOLUTION[0] - 100, 20,
                                Brick.DIMENSION, int(rect_pixel_length / 2))
        self._figure_factory = FigureFactory(self._field)
        self._figure = next(self._figure_factory)
        self._next_figure = next(self._figure_factory)
        self._score = Score()
        self._control = Control(START_FPS)

        # init speed and game state
        self._stepover = START_GAME_STEPOVER
        self._nostep = self._stepover
        self._looping = True
        self._was_started = False
        self._has_stopped = False
        self._is_paused = True
Exemple #8
0
 def _initEmptyBoard(self):
     """
     :return: the initialized board
     """
     board = [[Square(None, i, j) for j in range(5)] for i in range(5)]
     board[0][0] = Square(Note(False), 0, 0)
     board[0][1] = Square(Governance(False), 0, 1)
     board[0][2] = Square(Relay(False), 0, 2)
     board[0][3] = Square(Shield(False), 0, 3)
     board[0][4] = Square(Drive(False), 0, 4)
     board[1][4] = Square(Preview(False), 1, 4)
     board[3][0] = Square(Preview(True), 3, 0)
     board[4][0] = Square(Drive(True), 4, 0)
     board[4][1] = Square(Shield(True), 4, 1)
     board[4][2] = Square(Relay(True), 4, 2)
     board[4][3] = Square(Governance(True), 4, 3)
     board[4][4] = Square(Note(True), 4, 4)
     return board
Exemple #9
0
 def getPreviewXML(self, sources=None):
     # Preview returns an empty preview tag if it fails
     preview = Preview()
     raw_preview_xml = preview.preview(sources)
     if raw_preview_xml:
         try:
             preview_xml = etree.fromstring(raw_preview_xml)
         except SyntaxError, ex:
             # FIX ME This is going to  go bad at some point
             logger.error('Error with xml from preview:\n %s' % str(ex))
             pass
Exemple #10
0
    def __init__(self, instance, element, track, timeline):
        goocanvas.Group.__init__(self)
        View.__init__(self)
        Zoomable.__init__(self)
        self.app = instance
        self.track = track
        self.timeline = timeline
        self.namewidth = 0
        self.nameheight = 0

        self.bg = goocanvas.Rect(height=self.height, line_width=0)

        self.content = Preview(element)

        self.name = goocanvas.Text(x=NAME_HOFFSET + NAME_PADDING,
                                   y=NAME_VOFFSET + NAME_PADDING,
                                   operator=cairo.OPERATOR_ADD,
                                   alignment=pango.ALIGN_LEFT)
        self.namebg = goocanvas.Rect(radius_x=2,
                                     radius_y=2,
                                     x=NAME_HOFFSET,
                                     y=NAME_VOFFSET,
                                     line_width=0)

        self.start_handle = StartHandle(self.app,
                                        element,
                                        timeline,
                                        height=self.height)
        self.end_handle = EndHandle(self.app,
                                    element,
                                    timeline,
                                    height=self.height)

        self.selection_indicator = goocanvas.Rect(
            visibility=goocanvas.ITEM_INVISIBLE,
            line_width=0.0,
            height=self.height)

        for thing in (self.bg, self.content, self.selection_indicator,
                      self.start_handle, self.end_handle, self.namebg,
                      self.name):
            self.add_child(thing)

        for prop, interpolator in element.getInterpolators().itervalues():
            self.add_child(Curve(instance, element, interpolator, 50))

        self.element = element
        self.settings = instance.settings
        self.normal()
Exemple #11
0
    def update(self, dt):
        for i in self.buttons:
            i.update(dt)
            if i.path is not None:
                self.root = i.path
                i.path = None
                self.LoadImagePaths()

        if self.is_imagesloaded[2] is not None:
            self.LoadImagesLabel()
            self.preview = Preview(self.image_paths, 280, 100)
            self.is_imagesloaded[2] = None

        if self.preview is not None:
            self.preview.update(dt)
Exemple #12
0
    def set_sizes(self, h_res, v_res, size):
        if h_res == "auto":
            screen = self.screen()
            self.ppix = screen.physicalDotsPerInchX()
            self.ppiy = screen.physicalDotsPerInchY()
            h_res = screen.geometry().width()
            v_res = screen.geometry().height()
            #if self.ppix != self.ppiy:
            #    print("WARNING! due to the properties of your screen angles are slightly distorted and length of diagonals are approximations")
        else:
            diagonal_res = math.sqrt(int(h_res)**2 + int(v_res)**2)
            self.ppix = diagonal_res / float(size)  # Pixels per inch
            self.ppiy = self.ppix

        self.preview = Preview(h_res, v_res, self)
        self.preview.show()
        self.h_res, self.v_res = h_res, v_res
    def __init__(self, parent):
        super(DetailFrame, self).__init__(parent)
        layout = QVBoxLayout(self)
        layout.setContentsMargins(20, 15, 20, 20)

        self.title = Title('', 23)
        titleLayout = QHBoxLayout()
        titleLayout.setAlignment(Qt.AlignTop)
        titleLayout.addWidget(QLabel(' ' * 5))
        titleLayout.addWidget(self.title, 1)
        layout.addLayout(titleLayout, 0)

        detailLayout = QGridLayout()
        detailLayout.setColumnStretch(0, self.width() * 0.618)
        detailLayout.setColumnStretch(1, self.width() * (1 - 0.618))

        self.preview = Preview()
        self.info = Info()
        detailLayout.addWidget(self.preview, 0, 0)
        detailLayout.addWidget(self.info, 0, 1)

        layout.addLayout(detailLayout, 1)
Exemple #14
0
    def __initUI(self):
        """
		Initialize the GUI
		"""
        # Layout
        layout = QtGui.QHBoxLayout()
        self.__mainWidget = QtGui.QWidget()
        self.__mainWidget.setLayout(layout)
        self.setCentralWidget(self.__mainWidget)

        # Kinect image
        vLayout = QtGui.QVBoxLayout()
        self.__previewImage = Preview(self.__kinect)
        vLayout.addWidget(QtGui.QLabel(u"Image directe :"))
        vLayout.addWidget(self.__previewImage)
        layout.addLayout(vLayout)

        # Object image
        vLayout = QtGui.QVBoxLayout()
        self.__objectImage = QtGui.QLabel()
        vLayout.addWidget(QtGui.QLabel(u"Objet à imprimer :"))
        vLayout.addWidget(self.__objectImage)
        vLayout.addStretch(1)
        self.__captureButton = QtGui.QPushButton(u"Photographier")
        vLayout.addWidget(self.__captureButton)
        self.__exportButton = QtGui.QPushButton(u"Exporter")
        vLayout.addWidget(self.__exportButton)
        layout.addLayout(vLayout)
        self.__refreshObjectImage()

        # Center the window
        geo = self.frameGeometry()
        geo.moveCenter(QtGui.QDesktopWidget().availableGeometry().center())
        self.move(geo.topLeft())
        # Title
        self.setWindowTitle("Photomaton")
Exemple #15
0
    def setup_app(self):
        self.setupActions()
        splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
        self.tree = Tree()
        self.editor = Editor()
        self.highlighter = Highlighter(self.editor.document(), 'rst')

        self.tab_widget = QtWidgets.QTabWidget()
        self.preview = Preview()
        self.pdf_pane = PDFPane()
        self.tab_widget.addTab(self.preview, "HTML")
        self.tab_widget.addTab(self.pdf_pane, "PDF")

        self.file_path = None
        self.output_html_path = None

        self.setCentralWidget(splitter)
        splitter.addWidget(self.tree)
        splitter.addWidget(self.editor)

        splitter.addWidget(self.tab_widget)

        splitter.setSizes([300, 950, 1350])

        self.setWindowTitle("Sphinx Docs Editor")
        self.createMenus()
        self.createToolBars()
        self.resize(300 + 950 + 1350, 1400)

        try:
            with open('./config.json', 'r') as f:
                c = json.load(f)
            path = c['last_folder']
            self.openFolder(path)
        except:
            pass
Exemple #16
0
    def _create_widgets(self):
        editor_frame = tk.LabelFrame(self, text="Editor")
        editor_frame.grid(row=0, column=0, sticky="NEWS")
        editor_frame.columnconfigure(0, weight=1)
        editor_frame.rowconfigure(0, weight=1)

        preview_frame = tk.LabelFrame(self, text="Preview")
        preview_frame.grid(row=0, column=1, sticky="NEWS")
        preview_frame.columnconfigure(0, weight=1)
        preview_frame.rowconfigure(0, weight=1)

        self.__text_field = tk.Text(
            editor_frame,
            undo=True,
            wrap=tk.WORD,
            font="fixed",
        )
        self.__text_field.grid(sticky="NEWS")
        self.__text_field.tag_config(self._syntax_error_tag,
                                     background="red",
                                     foreground="white")

        self.__preview = Preview(preview_frame, self._on_new_figure_created,
                                 self._on_figure_updated)
# -*- coding: utf-8 -*-
import sys
import os

from PyQt5.QtCore import QCoreApplication, QSettings, QResource
from PyQt5.QtGui import QGuiApplication, QIcon
from PyQt5.QtQml import QQmlApplicationEngine

from preview import Preview

QResource.registerResource("_ninjapreview_resource.rcc")

qApp = QGuiApplication(sys.argv)

QCoreApplication.setOrganizationName("Deuteronomy Works")
QCoreApplication.setApplicationName("Ninja-Preview")
settings = QSettings()

qApp.setWindowIcon(QIcon(":icons/logo.png"))

engine = QQmlApplicationEngine()

preview = Preview()

engine.load("qrc:///UI/main.qml")
engine.rootObjects()[0].setProperty('preview', preview)
engine.quit.connect(qApp.quit)

sys.exit(qApp.exec_())