Exemple #1
0
    def __init__(self, parent, progress_bar=FALSE, message=''):
        self.parent = parent

        self.statusBar = parent.statusBar()
        self.__statusTimer = QTimer(self.parent)

        self.__statusTimer.timeout.connect(self.reset_message)

        self.__statusLabel = QLabel("msg", self.statusBar)
        self.tooltip = Tooltip('')
        self.tooltip.addWidget(self.__statusLabel)

        self.last_status_message = ''

        pixmap = QPixmap(":images/yellow.png")

        self.pixmapLabel = QLabel("image", self.statusBar)
        self.pixmapLabel.setPixmap(pixmap)

        self.statusBar.addWidget(self.pixmapLabel)
        self.statusBar.addWidget(self.__statusLabel)
        if progress_bar:
            self.progressBar = QProgressBar(self.statusBar)
            self.statusBar.addWidget(self.progressBar, 1, TRUE)

        if message:
            self.set_message(message)
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.name = "Last Hope"
        self.width = WIDTH
        self.height = HEIGHT

        self.rect = pygame.Rect(0, 0, WIDTH, HEIGHT)
        spritesheet = pygame.image.load("../assets/images/OtherSheet.png").convert_alpha()
        sprite_rect = pygame.Rect(1185, 192, 32, 32)
        image = spritesheet.subsurface(sprite_rect).copy()
        self.image = pygame.transform.smoothscale(image, (WIDTH, HEIGHT))

        icon_rect = pygame.Rect(640, 192, 32, 32)
        icon = spritesheet.subsurface(icon_rect).copy()
        self.icon = pygame.transform.smoothscale(icon, (ICON_WIDTH, ICON_HEIGHT))

        self.melee = False
        self.friends_usable = False
        self.enemies_usable = True
        self.has_effect = True

        self.effect = Tick()

        self.tooltip = Tooltip("Last Hope",
                               "100 Energy",
                               "The artifact is glowing softly")
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)

        self.name = "Energize"

        self.rect = None
        spritesheet = pygame.image.load(
            "../assets/images/OtherSheet.png").convert_alpha()
        self.image = None

        icon_rect = pygame.Rect(96, 256, 32, 32)
        icon = spritesheet.subsurface(icon_rect).copy()
        self.icon = pygame.transform.smoothscale(icon,
                                                 (ICON_WIDTH, ICON_HEIGHT))

        self.energy_cost = 0

        self.melee = False
        self.friends_usable = True
        self.enemies_usable = False
        self.has_effect = False

        self.tooltip = Tooltip(
            "Energize", "No Cost",
            "Recharge the energy of an ally (or yourself!)")
Exemple #4
0
    def __init__(self, parent, progress_bar=FALSE, message=''):
        self.parent = parent

        self.statusBar = parent.statusBar()
        self.__statusTimer = QTimer(self.parent)

        self.__statusTimer.timeout.connect(self.reset_message)

        self.__statusLabel = QLabel("msg", self.statusBar)
        self.tooltip = Tooltip('')
        self.tooltip.addWidget(self.__statusLabel)

        self.last_status_message = ''

        pixmap = QPixmap(":images/yellow.png")

        self.pixmapLabel = QLabel("image", self.statusBar)
        self.pixmapLabel.setPixmap(pixmap)

        self.statusBar.addWidget(self.pixmapLabel)
        self.statusBar.addWidget(self.__statusLabel)
        if progress_bar:
            self.progressBar = QProgressBar(self.statusBar)
            self.statusBar.addWidget(self.progressBar, 1, TRUE)

        if message:
            self.set_message(message)
Exemple #5
0
    def __init__(self, x, y, int):
        pygame.sprite.Sprite.__init__(self)
        self.name = "Fireball"
        self.x = x
        self.y = y
        self.width = WIDTH
        self.height = HEIGHT

        self.rect = pygame.Rect(x, y, WIDTH, HEIGHT)
        spritesheet = pygame.image.load(
            "../assets/images/OtherSheet.png").convert_alpha()
        sprite_rect = pygame.Rect(1185, 192, 32, 32)
        image = spritesheet.subsurface(sprite_rect).copy()
        self.image = pygame.transform.smoothscale(image, (WIDTH, HEIGHT))

        icon_rect = pygame.Rect(288, 1376, 32, 32)
        icon = spritesheet.subsurface(icon_rect).copy()
        self.icon = pygame.transform.smoothscale(icon,
                                                 (ICON_WIDTH, ICON_HEIGHT))

        self.melee = False
        self.friends_usable = False
        self.enemies_usable = True
        self.has_effect = True

        self.effect = Burning()

        self.tooltip = Tooltip(
            "Fireball", "30 Energy",
            "Hurls a fiery ball at the enemy, causing it to burn over time")
Exemple #6
0
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.name = "Heal"

        self.rect = None
        spritesheet = pygame.image.load(
            "../assets/images/OtherSheet.png").convert_alpha()
        self.image = None

        icon_rect = pygame.Rect(1248, 320, 32, 32)
        icon = spritesheet.subsurface(icon_rect).copy()
        self.icon = pygame.transform.smoothscale(icon,
                                                 (ICON_WIDTH, ICON_HEIGHT))

        self.energy_cost = ENERGY_COST

        self.melee = False
        self.friends_usable = True
        self.enemies_usable = False

        self.tooltip = Tooltip(
            "Heal", "40 Energy",
            "Restores the health of an ally (or yourself!)")
Exemple #7
0
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)

        self.name = "Power Attack"

        self.rect = None
        spritesheet = pygame.image.load(
            "../assets/images/OtherSheet.png").convert_alpha()
        self.image = None

        icon_rect = pygame.Rect(64, 1504, 32, 32)
        icon = spritesheet.subsurface(icon_rect).copy()
        self.icon = pygame.transform.smoothscale(icon,
                                                 (ICON_WIDTH, ICON_HEIGHT))

        self.melee = True
        self.friends_usable = False
        self.enemies_usable = True
        self.has_effect = False

        self.tooltip = Tooltip(
            "Power Attack", "25 Health",
            "An all-out melee attack, the execution of which "
            "will be painful for both you and the enemy")
Exemple #8
0
    def on_mouse_item_enter(self, widget, itemid):
        seed = objects[itemid]
        otype = objects.get("type", "object")

        #Item is seed
        if otype == "seed":
            data = [
                ["Name", seed["name"]],
                ["Description", seed["description"]],
                ["Quantity", str(seed["growquantity"])],
                ["Grow in", str(seed["growtime"] / 60) + " minutes"],
                ["Required level",
                 str(seed.get("requiredlevel", 1))],
            ]
        #Item is object
        else:
            data = [
                ["Name", seed["name"]],
                ["Description", seed["description"]],
                ["Required level",
                 str(seed.get("requiredlevel", 1))],
            ]
        mx, my = pygame.mouse.get_pos()
        self.tooltip = [Tooltip((mx + 5, my + 5), data), widget]
Exemple #9
0
    def __init__(self, master):
        self.initialdir = os.getcwd()
        master.title(
            'OBJ <--> S3O - By Beherith - Thanks to Muon\'s wonderful s3o library!'
        )
        frame = Frame(master)
        objtos3oframe = Frame(master, bd=1, relief=SUNKEN)
        s3otoobjframe = Frame(master, bd=3, relief=SUNKEN)
        opts3oframe = Frame(master, bd=3, relief=SUNKEN)

        clearaoframe = Frame(master, bd=3, relief=SUNKEN)
        printaoframe = Frame(master, bd=3, relief=SUNKEN)
        generateaoframe = Frame(master, bd=3, relief=SUNKEN)
        xnormalframe = Frame(generateaoframe, bd=3, relief=SUNKEN)
        aooptsframe = Frame(generateaoframe, bd=3, relief=SUNKEN)
        aooptsframe2 = Frame(generateaoframe, bd=3, relief=SUNKEN)
        aoplateframe = Frame(generateaoframe, bd=3, relief=SUNKEN)
        swaptexframe = Frame(master, bd=3, relief=SUNKEN)

        frame.pack()
        objtos3oframe.pack(side=TOP, fill=X)
        s3otoobjframe.pack(side=TOP, fill=X)
        opts3oframe.pack(side=TOP, fill=X)
        clearaoframe.pack(side=TOP, fill=X)
        printaoframe.pack(side=TOP, fill=X)
        generateaoframe.pack(side=TOP, fill=X)
        xnormalframe.pack(side=TOP, fill=X)
        aooptsframe.pack(side=TOP, fill=X)
        aooptsframe2.pack(side=TOP, fill=X)
        swaptexframe.pack(side=TOP, fill=X)
        quitbutton = Button(frame, text="QUIT", fg="red", command=frame.quit)
        quitbutton.pack(side=TOP)
        Tooltip(quitbutton, text="Quit the application", wraplength=200)

        self.prompts3ofilename = IntVar()
        optimizes3obutton = Button(opts3oframe,
                                   text='Optimize s3o',
                                   command=self.optimizes3o)
        optimizes3obutton.pack(side=LEFT)
        Tooltip(
            optimizes3obutton,
            text=
            "Select an S3O file, and clean up redundant vertices, perform vertex cache optimization and fix null normals. Modifies S3O file in place.",
            wraplength=400)

        Label(
            opts3oframe,
            text=
            'Removes redundant vertices and performs vertex cache optimization'
        ).pack(side=LEFT)

        #-----AO stuff----
        clearaos3obutton = Button(clearaoframe,
                                  text='Clear AO s3o',
                                  command=self.clearaos3o)
        clearaos3obutton.pack(side=LEFT)
        Tooltip(
            clearaos3obutton,
            text=
            "If no list is specified, resets all vertex ambient ambient occlusion data in-place. If list is specified, then AO data will only removed from those pieces. Use this to clear AO from spinning or fully occluded pieces.",
            wraplength=400)

        Label(clearaoframe,
              text='Reset all AO data, or list pieces to remove from:').pack(
                  side=LEFT)

        self.clearaopiecelist = StringVar()
        clearaopiecelistentry = Entry(clearaoframe,
                                      width=32,
                                      textvariable=self.clearaopiecelist)
        clearaopiecelistentry.pack(side=LEFT)
        Tooltip(
            clearaopiecelistentry,
            text="A comma separated list of pieces to remove AO data from.",
            wraplength=200)

        self.ao_zerolevel = StringVar()
        self.ao_zerolevel.set("200")
        Label(clearaoframe, text='Set to:').pack(side=LEFT)
        aozerolevelentry = Entry(clearaoframe,
                                 width=4,
                                 textvariable=self.ao_zerolevel)
        aozerolevelentry.pack(side=LEFT)
        Tooltip(
            aozerolevelentry,
            text=
            "What AO value to reset to, where 0 is fully black, 255 is fully white and ~200 is default."
        )

        printaos3obutton = Button(printaoframe,
                                  text='Print AO information',
                                  command=self.printaos3o)
        printaos3obutton.pack(side=LEFT)
        Tooltip(
            printaos3obutton,
            text=
            "Prints information about the AO data preset in a model to console. For developers and debugging."
        )

        self.xnormalpath = StringVar()
        self.xnormalpath.set(
            "C:\\Program Files\\xNormal\\3.19.3\\x64\\xNormal.exe")
        Label(xnormalframe, text='Path to xNormal:').pack(side=LEFT)
        xnormalpathentry = Entry(xnormalframe,
                                 width=84,
                                 textvariable=self.xnormalpath)
        xnormalpathentry.pack(side=LEFT)
        Tooltip(
            xnormalpathentry,
            text=
            "Set your path to xNormal.exe here. Sorry this is not remembered on relaunch. Its easier if you just install xnormal to the default path."
        )

        Label(aooptsframe, text='Groundplate:').pack(side=LEFT)
        self.aotype_building = IntVar()
        aotypebuildingcheckbutton = Checkbutton(aooptsframe,
                                                text='Building (big)',
                                                variable=self.aotype_building)
        aotypebuildingcheckbutton.pack(side=LEFT)
        Tooltip(
            aotypebuildingcheckbutton,
            text=
            "Enable this when baking AO for buildings. This puts a larger than normal groundplate underneath the unit, to make sure the building is only lit from the top hemisphere."
        )

        self.aotype_flying = IntVar()
        aotypeflyingcheckbutton = Checkbutton(aooptsframe,
                                              text='Flying (none)',
                                              variable=self.aotype_flying)
        aotypeflyingcheckbutton.pack(side=LEFT)
        Tooltip(
            aotypeflyingcheckbutton,
            text=
            "Use for aircraft, this remove the groundplate from under the unit, so it can get lit from all directions."
        )

        self.ao_explode = IntVar()
        aoexplodecheckbutton = Checkbutton(aooptsframe,
                                           text='Explode all piecewise',
                                           variable=self.ao_explode)
        aoexplodecheckbutton.pack(side=LEFT)
        Tooltip(
            aoexplodecheckbutton,
            text=
            "Move ALL pieces in a model far away from each other, so they dont occlude each other. Use this for cars with wheels, or for models that open and unfold."
        )

        self.ao_minclamp = StringVar()
        self.ao_minclamp.set("0")
        Label(aooptsframe, text='Clamp:').pack(side=LEFT)
        aominclampentry = Entry(aooptsframe,
                                width=4,
                                textvariable=self.ao_minclamp)
        aominclampentry.pack(side=LEFT)
        Tooltip(
            aominclampentry,
            text=
            "The darkest possible level AO shading will go to. 0 means even the darkes is allowed, 255 means that everything will be full white. 128 is good if you dont want peices to go too dark"
        )

        self.ao_bias = StringVar()
        self.ao_bias.set("0.0")
        Label(aooptsframe, text='Bias:').pack(side=LEFT)
        aobiasentry = Entry(aooptsframe, width=4, textvariable=self.ao_bias)
        aobiasentry.pack(side=LEFT)
        Tooltip(
            aobiasentry,
            text=
            "Add this much to every vertex AO value, positive values brighten, negative values darken. Sane range [-255;255] "
        )

        self.ao_gain = StringVar()
        self.ao_gain.set("1.0")
        Label(aooptsframe, text='Gain:').pack(side=LEFT)
        aogainentry = Entry(aooptsframe, width=4, textvariable=self.ao_gain)
        aogainentry.pack(side=LEFT)
        Tooltip(
            aogainentry,
            text=
            "Multiply calculated AO terms with this value. A value of 2.0 would double the brightness of each value, 0.5 would half it. AO_out = min(255, max(clamp, AO_in * bias + gain)) "
        )

        self.ao_explodepieceslist = StringVar()
        Label(aooptsframe2, text='List of pieces to explode').pack(side=LEFT)
        aoexplodepieceslistentry = Entry(
            aooptsframe2, width=76, textvariable=self.ao_explodepieceslist)
        aoexplodepieceslistentry.pack(side=LEFT)
        Tooltip(
            aoexplodepieceslistentry,
            text=
            "Comma separated list of pieces that should not be occluded by other pieces"
        )

        getpiecelistbutton = Button(aooptsframe2,
                                    text='Get',
                                    command=self.getpiecelist)
        getpiecelistbutton.pack(side=LEFT)
        Tooltip(getpiecelistbutton,
                text="Load the list of pieces from an S3O model")

        bakeaobutton = Button(
            generateaoframe,
            text='Bake Vertex AO with above parameters for (multiple) units',
            command=self.bakeao)
        bakeaobutton.pack(side=TOP)
        Tooltip(
            bakeaobutton,
            text=
            "Load (multiple) S3O files, and perform the AO baking, modifying the S3O files in-place"
        )

        # ---- AO plate stuff
        bakeaoplatebutton = Button(aoplateframe,
                                   text='Bake AO plane for building(s)',
                                   command=self.bakeaoplate)
        bakeaoplatebutton.pack(side=LEFT)
        Tooltip(
            bakeaoplatebutton,
            text=
            "Load (multiple) S3O files, and perform the AO baking, and output the mymodel_aoplane.dds files"
        )

        self.aoplate_xsize = StringVar()
        self.aoplate_xsize.set("5")
        Label(aoplateframe, text='Size X:').pack(side=LEFT)
        aoplatexentry = Entry(aoplateframe,
                              width=4,
                              textvariable=self.aoplate_xsize)
        aoplatexentry.pack(side=LEFT)
        Tooltip(
            aoplatexentry,
            text=
            "X Size of the footprint of the building (unitdef: buildinggrounddecalsizex)"
        )

        self.aoplate_zsize = StringVar()
        self.aoplate_zsize.set("5")
        Label(aoplateframe, text='Size Z:').pack(side=LEFT)
        aoplatezentry = Entry(aoplateframe,
                              width=4,
                              textvariable=self.aoplate_zsize)
        aoplatezentry.pack(side=LEFT)
        Tooltip(
            aoplatezentry,
            text=
            "Z Size of the footprint of the building (unitdef: buildinggrounddecalsizeZ)"
        )

        self.aoplate_rez = StringVar()
        self.aoplate_rez.set("128")
        Label(aoplateframe, text='Resolution:').pack(side=LEFT)
        aoplateresentry = Entry(aoplateframe,
                                width=4,
                                textvariable=self.aoplate_rez)
        aoplateresentry.pack(side=LEFT)
        Tooltip(
            aoplateresentry,
            text=
            "Resolution of the generated image, default 128, use power-of-two values"
        )

        aoplateframe.pack(side=TOP, fill=X)
        #--- end AO stuff

        swaptexbutton = Button(swaptexframe,
                               text='Override texture',
                               command=self.swaptex)
        swaptexbutton.pack(side=LEFT)
        Tooltip(
            swaptexbutton,
            text=
            "Change only the textures of (multiple) S3O files, to the ones specified in Tex1 and Tex2"
        )

        Label(swaptexframe, text='Tex1:').pack(side=LEFT)
        self.tex1 = StringVar()
        Entry(swaptexframe, width=20, textvariable=self.tex1).pack(side=LEFT)
        Label(swaptexframe, text='Tex2:').pack(side=LEFT)
        self.tex2 = StringVar()
        Entry(swaptexframe, width=20, textvariable=self.tex2).pack(side=LEFT)

        openobjbutton = Button(objtos3oframe,
                               text='Convert OBJ to S3O',
                               command=self.openobj)
        openobjbutton.pack(side=LEFT)
        Tooltip(
            openobjbutton,
            text=
            "Choose any mymodel.OBJ file(s), and convert them into mymodel.S3O. Each object in an OBJ file will be a separate piece in the S3O file. If the OBJ file was created by this tool, and the object names were left intact, you will retain all piece hiearchy and origins information."
        )

        prompts3ofilenamecheckbutton = Checkbutton(
            objtos3oframe,
            text='Prompt output filename',
            variable=self.prompts3ofilename)
        prompts3ofilenamecheckbutton.pack(side=LEFT)
        Tooltip(
            prompts3ofilenamecheckbutton,
            text=
            "Allows you to choose what name you want to save your S3O file as."
        )

        opens3obutton = Button(s3otoobjframe,
                               text='Convert S3O to OBJ',
                               command=self.opens3o)
        opens3obutton.pack(side=LEFT)
        Tooltip(
            opens3obutton,
            text=
            "Convert mymodel.S3O into and editable mymodel.OBJ, while keeping all S3O information in the object names."
        )

        self.optimize_for_wings3d = IntVar()
        self.optimize_for_wings3d.set(1)
        optimizeforwingscheckbutton = Checkbutton(
            s3otoobjframe,
            text='Optimize for Wings3d',
            variable=self.optimize_for_wings3d)
        optimizeforwingscheckbutton.pack(side=LEFT)
        Tooltip(
            optimizeforwingscheckbutton,
            text=
            "This should be ON, and it specifies hard/soft edges via .obj smoothing group operators, and ensures mesh continuity across triangles"
        )

        self.promptobjfilename = IntVar()
        promptobjfilenamecheckbutton = Checkbutton(
            s3otoobjframe,
            text='Prompt output filename',
            variable=self.promptobjfilename)
        promptobjfilenamecheckbutton.pack(side=LEFT)
        Tooltip(
            promptobjfilenamecheckbutton,
            text=
            "Allows you to choose what name you want to save your OBJ file as."
        )

        self.transform = IntVar()
        transformcheckbutton = Checkbutton(objtos3oframe,
                                           text='Transform UV coords:',
                                           variable=self.transform)
        transformcheckbutton.pack(side=LEFT)
        Tooltip(
            transformcheckbutton,
            text=
            "Perform a linear transformation of the UV space of a model when converting S3O to OBJ"
        )

        Label(objtos3oframe, text='U=').pack(side=LEFT)
        self.transformA = StringVar()
        transformaentry = Entry(objtos3oframe,
                                width=4,
                                textvariable=self.transformA)
        transformaentry.pack(side=LEFT)
        Tooltip(
            transformaentry,
            text="How much to multiply all U (horizontal) coordinates with")
        self.transformA.set('1')

        Label(objtos3oframe, text='* U +').pack(side=LEFT)
        self.transformB = StringVar()
        transformbentry = Entry(objtos3oframe,
                                width=4,
                                textvariable=self.transformB)
        transformbentry.pack(side=LEFT)
        Tooltip(transformbentry,
                text="How much to add to all U (horizontal) coordinates")
        self.transformB.set('0')

        Label(objtos3oframe, text='    V=').pack(side=LEFT)
        self.transformC = StringVar()
        transformcentry = Entry(objtos3oframe,
                                width=4,
                                textvariable=self.transformC)
        transformcentry.pack(side=LEFT)
        Tooltip(transformcentry,
                text="How much to multiply all V (vertical) coordinates with")
        self.transformC.set('1')

        Label(objtos3oframe, text='* V +').pack(side=LEFT)
        self.transformD = StringVar()
        transformdentry = Entry(objtos3oframe,
                                width=4,
                                textvariable=self.transformD)
        transformdentry.pack(side=LEFT)
        Tooltip(transformdentry,
                text="How much to add to all U (horizontal) coordinates")
        self.transformD.set('0')

        Label(
            frame,
            wraplength=600,
            justify=LEFT,
            text=
            'Instructions and notes:\n1. Converting S3O to OBJ:\n Open an s3o file, and the obj file will be saved with the same name and an .obj extension\n The name of each object in the .obj file will reflect the naming and pieces of the s3o file. All s3o data is retained, and is listed as a series of parameters in the object\'s name.\nExample:\no base,ox=-0.00,oy=0.00,oz=0.00,p=,mx=-0.00,my=4.00,mz=0.00,r=17.50,h=21.00,t1=tex1.png,t2=tex2.png\n ALL s3o info is retained, including piece hierarchy, piece origins, smoothing groups, vertex normals, and even degenerate pieces with no geometry used as emit points and vectors. These emit pieces will be shown as triangles with their correct vertex ordering.\n2. Converting OBJ to S3O:\n The opened .obj file will be converted into s3o. If the piece names contain the information as specified in the above example, the entire model hierarchy will be correctly converted. If it doesnt, then the program will convert each object as a child piece of an empty base object.'
        ).pack(side=BOTTOM)
Exemple #10
0
class Status_Bar:
    def __init__(self, parent, progress_bar=FALSE, message=''):
        self.parent = parent

        self.statusBar = parent.statusBar()
        self.__statusTimer = QTimer(self.parent)

        self.__statusTimer.timeout.connect(self.reset_message)

        self.__statusLabel = QLabel("msg", self.statusBar)
        self.tooltip = Tooltip('')
        self.tooltip.addWidget(self.__statusLabel)

        self.last_status_message = ''

        pixmap = QPixmap(":images/yellow.png")

        self.pixmapLabel = QLabel("image", self.statusBar)
        self.pixmapLabel.setPixmap(pixmap)

        self.statusBar.addWidget(self.pixmapLabel)
        self.statusBar.addWidget(self.__statusLabel)
        if progress_bar:
            self.progressBar = QProgressBar(self.statusBar)
            self.statusBar.addWidget(self.progressBar, 1, TRUE)

        if message:
            self.set_message(message)


    def set_message(self, message='', duration=0, replace=FALSE, tooltip='', pixmap=''):
        """sets the status bar message label to message.

        if duration is > 0 than the message is displayed for duration seconds.

        if duration is > 0 and replace is true then after duration seconds
        have elapsed, the previous message is displayed.
        """

        self.__statusTimer.stop()
        self.last_status_message = unicode(self.__statusLabel.text())
        self.replace_status_message = replace

        self.__statusLabel.setText(message)

        if duration > 0:
            self.__statusTimer.setSingleShot(True)
            self.__statusTimer.start(1000 * duration)

        if tooltip:
            self.tooltip.set_tooltip(tooltip)
        else:
            self.tooltip.clear_tooltip()

        if pixmap:
            self.pixmapLabel.setPixmap(pixmap)



    def reset_message(self):
        self.__statusTimer.stop()
        if self.replace_status_message:
            self.__statusLabel.setText(self.last_status_message)
        else:
            self.__statusLabel.setText('')



    def geometry(self):
        return self.statusBar.geometry()
Exemple #11
0
class Status_Bar:
    def __init__(self, parent, progress_bar=FALSE, message=''):
        self.parent = parent

        self.statusBar = parent.statusBar()
        self.__statusTimer = QTimer(self.parent)

        self.__statusTimer.timeout.connect(self.reset_message)

        self.__statusLabel = QLabel("msg", self.statusBar)
        self.tooltip = Tooltip('')
        self.tooltip.addWidget(self.__statusLabel)

        self.last_status_message = ''

        pixmap = QPixmap(":images/yellow.png")

        self.pixmapLabel = QLabel("image", self.statusBar)
        self.pixmapLabel.setPixmap(pixmap)

        self.statusBar.addWidget(self.pixmapLabel)
        self.statusBar.addWidget(self.__statusLabel)
        if progress_bar:
            self.progressBar = QProgressBar(self.statusBar)
            self.statusBar.addWidget(self.progressBar, 1, TRUE)

        if message:
            self.set_message(message)

    def set_message(self,
                    message='',
                    duration=0,
                    replace=FALSE,
                    tooltip='',
                    pixmap=''):
        """sets the status bar message label to message.

        if duration is > 0 than the message is displayed for duration seconds.

        if duration is > 0 and replace is true then after duration seconds
        have elapsed, the previous message is displayed.
        """

        self.__statusTimer.stop()
        self.last_status_message = unicode(self.__statusLabel.text())
        self.replace_status_message = replace

        self.__statusLabel.setText(message)

        if duration > 0:
            self.__statusTimer.setSingleShot(True)
            self.__statusTimer.start(1000 * duration)

        if tooltip:
            self.tooltip.set_tooltip(tooltip)
        else:
            self.tooltip.clear_tooltip()

        if pixmap:
            self.pixmapLabel.setPixmap(pixmap)

    def reset_message(self):
        self.__statusTimer.stop()
        if self.replace_status_message:
            self.__statusLabel.setText(self.last_status_message)
        else:
            self.__statusLabel.setText('')

    def geometry(self):
        return self.statusBar.geometry()
Exemple #12
0
    def __init__(self):
        self.config = ConfigParser()
        self.window = tk.Tk()

        self.sharedlanguagefile = tk.StringVar(self.window)
        self.baseskindirectory = tk.StringVar(self.window)

        self.loadsharedlanguage_action = LoadSharedLanguageAction()
        self.loadskin_action = LoadSkinAction()
        self.checkactions = [
            CheckLoadedSkinAction(),
            CheckSkinFilesAction(),
            CheckIncludesAction(),
            CheckFontsAction(),
            CheckVariablesAction(),
            CheckExpressionsAction(),
            CheckSkinSettingsAction(),
            CheckSyntaxAction(),
            CheckMessagesAction(),
            CheckMediaFilesAction()
        ]

        self.window.title("Kodi Skin Tester")
        self.window.geometry("1200x680")
        self.window.resizable(False, False)

        self.messages = ThreadSafeConsole(master=self.window,
                                          width=100,
                                          height=24)
        self.messages.place(x=300, y=120, width=870, height=480)
        text_scrollbar_x = tk.Scrollbar(master=self.window,
                                        orient="horizontal",
                                        command=self.messages.xview)
        text_scrollbar_x.place(x=300, y=600, width=870, height=20)
        text_scrollbar_y = tk.Scrollbar(master=self.window,
                                        orient="vertical",
                                        command=self.messages.yview)
        text_scrollbar_y.place(x=1170, y=120, width=20, height=480)
        self.messages.configure(xscrollcommand=text_scrollbar_x.set)
        self.messages.configure(yscrollcommand=text_scrollbar_y.set)

        self.addmessage("action", "Starting Kodi Skin Tester...")
        self.addmessage(
            "info",
            "- Made by Malthus (Marijn Hubert) to test the Kodi skin 'Revolve'"
        )
        self.addmessage(
            "warning",
            "- Use this Kodi Skin Tester and its results at your own risk")
        self.addmessage("info", "Done")
        self.loadconfiguration()

        self.sharedlanguagefilelabel = tk.Label(
            self.window,
            textvariable=self.sharedlanguagefile,
            foreground='red',
            anchor='w')
        self.sharedlanguagefilelabel.place(x=310, y=10, width=590, height=30)
        self.baseskindirectorylabel = tk.Label(
            self.window,
            textvariable=self.baseskindirectory,
            foreground='red',
            anchor='w')
        self.baseskindirectorylabel.place(x=310, y=40, width=590, height=30)

        self.loadbuttonframe = tk.Frame()
        self.loadsharedlanguagebutton = tk.Button(
            master=self.loadbuttonframe,
            text="Load shared language file",
            command=self.loadsharedlanguagefromselectedfile)
        self.loadsharedlanguagebutton.place(x=0, y=0, width=280, height=30)
        tooltip = Tooltip(self.loadsharedlanguagebutton)
        self.loadsharedlanguagebutton.bind(
            "<Enter>", partial(tooltip.show, LOADSHAREDLANGUAGEFILE_TOOLTIP))
        self.loadsharedlanguagebutton.bind("<Leave>", partial(tooltip.hide))
        self.loadskinbutton = tk.Button(
            master=self.loadbuttonframe,
            text="Load skin from folder",
            command=self.loadskinfromselecteddirectory)
        self.loadskinbutton.place(x=0, y=30, width=280, height=30)
        tooltip = Tooltip(self.loadskinbutton)
        self.loadskinbutton.bind(
            "<Enter>", partial(tooltip.show, LOADSKINFROMDIRECTORY_TOOLTIP))
        self.loadskinbutton.bind("<Leave>", partial(tooltip.hide))
        self.reloadskinbutton = tk.Button(master=self.loadbuttonframe,
                                          text="Reload skin files",
                                          command=self.reloadskin)
        self.reloadskinbutton.place(x=0, y=60, width=280, height=30)
        tooltip = Tooltip(self.reloadskinbutton)
        self.reloadskinbutton.bind("<Enter>",
                                   partial(tooltip.show, RELOADSKIN_TOOLTIP))
        self.reloadskinbutton.bind("<Leave>", partial(tooltip.hide))
        self.loadbuttonframe.place(x=10, y=10, width=280, height=100)

        self.checkbuttonframe = tk.Frame()
        for index, action in enumerate(self.checkactions):
            button = tk.Button(master=self.checkbuttonframe,
                               text=action.getname(),
                               command=partial(self.executecheckaction,
                                               action),
                               width=60,
                               height=3)
            button.place(x=0, y=30 * index, width=280, height=30)
            tooltip = Tooltip(button)
            button.bind("<Enter>", partial(tooltip.show, action.description))
            button.bind("<Leave>", partial(tooltip.hide))
        self.checkbuttonframe.place(x=10, y=120, width=280, height=300)

        self.clearbutton = tk.Button(master=self.window,
                                     text="Clear",
                                     command=self.clearmessages)
        self.clearbutton.place(x=900, y=630, width=280, height=40)
        tooltip = Tooltip(self.clearbutton)
        self.clearbutton.bind("<Enter>",
                              partial(tooltip.show, CLEARMESSAGES_TOOLTIP))
        self.clearbutton.bind("<Leave>", partial(tooltip.hide))

        self.exitbutton = tk.Button(master=self.window,
                                    text="Close",
                                    command=self.exitprogram)
        self.exitbutton.place(x=10, y=630, width=280, height=40)
        tooltip = Tooltip(self.exitbutton)
        self.exitbutton.bind("<Enter>",
                             partial(tooltip.show, CLOSEPROGRAM_TOOLTIP))
        self.exitbutton.bind("<Leave>", partial(tooltip.hide))

        self.executeloadaction(self.loadsharedlanguage_action)
        self.executeloadaction(self.loadskin_action)
        self.window.mainloop()