Ejemplo n.º 1
0
 def runTestTransform(self, xOffset, yOffset, x, y, correction,
                      expectedResult):
     gui = Gui(ModelMock(), None)
     gui.xOffset = xOffset
     gui.yOffset = yOffset
     actualResult = gui._transform(x, y, correction)
     self.assertEqual(actualResult, expectedResult)
Ejemplo n.º 2
0
    def test_canvas(self):
        gui = Gui.Gui()
        ca = gui.ca()
        self.assertEqual(ca.width, 100)
        self.assertEqual(ca.height, 100)

        point = [50, 50]
        box = [[100, 200], [300, 500]]
        item = ca.arc(box)
        self.assertTrue(isinstance(item, Gui.Item))

        item = ca.line(box)
        self.assertTrue(isinstance(item, Gui.Item))

        item = ca.oval(box)
        self.assertTrue(isinstance(item, Gui.Item))

        item = ca.circle(point, 25)
        self.assertTrue(isinstance(item, Gui.Item))

        item = ca.polygon(box)
        self.assertTrue(isinstance(item, Gui.Item))

        item = ca.rectangle(box)
        self.assertTrue(isinstance(item, Gui.Item))

        item = ca.text(point, 'text')
        self.assertTrue(isinstance(item, Gui.Item))
Ejemplo n.º 3
0
def main():

    questionfile = ""
    appdir = os.path.dirname(sys.argv[0])
    questionfiles = os.listdir(appdir + "Preguntas")
    print("Using: " + appdir + "Preguntas\n")

    ok = 0
    wrong = 0

    gui = Gui.Gui(appdir)
    gui.show_intro()

    while 1:
        questionfile = ""
        while questionfile[0:1] != "q":
            questionfile = random.choice(questionfiles)
        try:
            qfile = open(appdir + "Preguntas/" + questionfile)
        except:
            sys.exit("ERROR: can't open question file " + questionfile)

        question = qfile.readline().replace("\n", "")
        question = question.replace("\r", "")
        question.encode('utf-8')

        answer1 = qfile.readline().replace("\n", "")
        answer1 = answer1.replace("\r", "")
        answer1.encode('utf-8')

        answer2 = qfile.readline().replace("\n", "")
        answer2 = answer2.replace("\r", "")
        answer2.encode('utf-8')

        answer3 = qfile.readline().replace("\n", "")
        answer3 = answer3.replace("\r", "")
        answer3.encode('utf-8')

        right_answer = qfile.readline().replace("\n", "")
        right_answer = right_answer.replace("\r", "")
        qfile.close

        gui.show_question(question, answer1, answer2, answer3)
        answer = gui.wait_for_answers()
        if answer == right_answer:
            ok = ok + 1
        else:
            wrong = wrong + 1

        if answer == "A":
            show = answer1
        elif answer == "B":
            show = answer2
        elif answer == "C":
            show = answer3
        gui.show_result(show, answer, right_answer)

        print("OK:", ok, " ERRORS:", wrong, "\n")
Ejemplo n.º 4
0
 def __init__(self, mx=10, my=10):
     self.board = Board(mx, my)
     self.gui = Gui(mx, my)
     self.last = sdl2.SDLK_UP
     self.dir = {
         sdl2.SDLK_UP: [-1, 0],
         sdl2.SDLK_DOWN: [1, 0],
         sdl2.SDLK_LEFT: [0, -1],
         sdl2.SDLK_RIGHT: [0, 1],
     }
Ejemplo n.º 5
0
    def draw(self, ca, start=0, end=None):
        a = ca.get_array(start, end)
        self.rows, self.cols = a.shape
        size = [self.cols * self.csize, self.rows * self.csize]

        self.gui = Gui.Gui()
        self.button = self.gui.bu(command=self.gui.quit)

        self.image = Image.new(mode='1', size=size, color='white')
        self.drawable = ImageDraw.Draw(self.image)
        self.draw_array(numpy.flipud(a))
Ejemplo n.º 6
0
def main():

    try:
        model = Model()
        controller = Controller(model)
        controller.start()
        gui = Gui(model, controller)
        gui.show()
        controller.stop()
    except FatalException, exc:
        print('Fehler', exc.getMessage())
Ejemplo n.º 7
0
Archivo: App.py Proyecto: PorterK/pyazo
def run():
    global app
    #Instantiate our app and Gui stuff.
    app = QApplication(sys.argv)
    gui = Gui()

    gui.on('release', doRelease)
    #Make the cursor the "cross cursor" for effect
    app.setOverrideCursor(QCursor(Qt.CrossCursor))
    #Exit when our app exits
    sys.exit(app.exec_())
Ejemplo n.º 8
0
def main():
    calendar = Calendar()
    calendar.init_credentials()
    calendar.init_create_calendar()

    event_list = Priority_Event_List(calendar)

    priority(event_list.priority_events)

    app = QApplication([])
    gui = Gui(calendar, event_list)
    sys.exit(app.exec_())
Ejemplo n.º 9
0
    def start_gui(self):
        '''
    @summary: Initialises and launches the ransomware GUI screen
    '''

        # Get Crypter start_time
        start_time = self.get_start_time()

        app = wx.App()
        #sys._MEIPASS = "******"
        crypter_gui = Gui.Gui(image_path=sys._MEIPASS,
                              start_time=start_time,
                              decrypter=self)

        crypter_gui.Show()
        app.MainLoop()
Ejemplo n.º 10
0
    def recognize(self):

        recognizer = cv2.face.LBPHFaceRecognizer_create()
        recognizer.read('trainer/trainer.yml')
        cascadePath = "haarcascade/haarcascade_frontalface_default.xml"
        faceCascade = cv2.CascadeClassifier(cascadePath)
        if sys.platform == 'win32':
            from imutils.video import WebcamVideoStream
            cap = WebcamVideoStream(src=0).start()
        else:
            from imutils.video.pivideostream import PiVideoStream
            cap = PiVideoStream().start()
        font = cv2.FONT_HERSHEY_COMPLEX
        d = database.Database().getAll()
        ls = {}
        for doc in d:
            ls[doc['id']] = doc['name']
        name = 'unknown'

        while True:
            im = cap.read()
            gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
            faces = faceCascade.detectMultiScale(gray, 1.2, 5)
            for (x, y, w, h) in faces:
                cv2.rectangle(im, (x, y), (x + w, y + h), (225, 0, 0), 2)
                Id, conf = recognizer.predict(gray[y:y + h, x:x + w])
                if sys.platform == 'win32':
                    if (conf <= 70):
                        name = ls.get(Id)
                        print(name, Id, conf)
                    else:
                        name = "who?"
                else:
                    if (conf >= 50):
                        name = ls.get(Id)
                        print(name, Id, conf)
                    else:
                        name = "who?"

                cv2.putText(im, str(name), (x, y + h), font, 1, (255, 255, 255))
            cv2.imshow('im', im)
            if cv2.waitKey(10) == ord('q'):
                break
        cap.stop()
        cv2.destroyAllWindows()
        Gui.Gui()
Ejemplo n.º 11
0
    def start_gui(self):
        '''
    @summary: Initialises and launches the ransomware GUI screen
    '''

        # Get Crypter start_time
        start_time = self.get_start_time()

        app = wx.App()
        # TODO Update this to new path and place in __init__
        #sys._MEIPASS = "******"
        crypter_gui = Gui.Gui(image_path=sys._MEIPASS,
                              start_time=start_time,
                              decrypter=self,
                              config=self.__config)

        crypter_gui.Show()
        app.MainLoop()
Ejemplo n.º 12
0
    def test_gui(self):
        gui = Gui.Gui()
        fr = gui.fr()
        endfr = gui.endfr()
        self.assertEqual(gui, endfr)

        row = gui.row()
        gui.rowweights([1, 2, 3])

        col = gui.col()
        gui.colweights([1, 2, 3])

        popfr = gui.popfr()

        self.assertEqual(popfr, row)

        en = gui.en()

        ca = gui.ca()
        self.assertTrue(isinstance(ca, Gui.GuiCanvas))

        la = gui.la()

        widget = gui.la()
        widget = gui.lb()
        widget = gui.bu()

        mb = gui.mb()
        widget = gui.mi(mb)

        widget = gui.te()
        widget = gui.sb()
        widget = gui.cb()

        size = tkinter.IntVar()
        widget = gui.rb(variable=size, value=1)

        widget = gui.st()
        self.assertTrue(isinstance(widget, Gui.Gui.ScrollableText))

        widget = gui.sc()
        self.assertTrue(isinstance(widget, Gui.Gui.ScrollableCanvas))

        gui.destroy()
Ejemplo n.º 13
0
 def __init__(self,startingx, startingy, width, height, filename):
     pygame.sprite.Sprite.__init__(self)
     self.image = pygame.Surface([32, 32])
     self.rect = self.image.get_rect()
     self.image.set_colorkey((0, 0, 0))
     self.rect.x = startingx
     self.rect.y = startingy
     self.velocity = 4
     self.image_left = pygame.image.load('./assets/pirate_left.png')
     self.image_right = pygame.image.load('./assets/pirate_right.png')
     self.deltax = 0
     self.deltay = 0
     self.collidedEntity = False
     self.dir = 0
     self.stamina = 100
     self.isSpaceHeld = False
     self.magic = 100
     self.currentWeapon = "sword"
     self.animationState = "idle"
     self.health = 100
     self.gui = Gui(self)
     self.canMove = True
     player_sprite.add(self)
     camera_sprite.add(self)
Ejemplo n.º 14
0
from Gui import *
from Util import *

Gui(Util.readConfig("deployer.cfg"))
Ejemplo n.º 15
0
 def init_inventory(self):
     self.visualInventory = Gui(100, 100)
Ejemplo n.º 16
0

def draw_simple_tree(base_x, base_y, height):  #Draws a single tree
    #First Trunk
    trunk_x1 = base_x - height * 0.05
    trunk_x2 = base_x + height * 0.05
    trunk_y1 = base_y
    trunk_y2 = base_y + height * 0.5
    canvas.rectangle([[trunk_x1, trunk_y1], [trunk_x2, trunk_y2]], \
                     fill='brown', width = 0)
    # draw crown
    # the polygon has 3 points, peak, lower left (LL), and lower right (LR)
    LL_x = base_x - height * 0.2
    LR_x = base_x + height * 0.2
    L_y = base_y + height * 0.3
    canvas.polygon([[base_x, base_y + height], [LL_x, L_y], [LR_x, L_y]], \
                   fill='darkgreen', width=0)


###################################################################DoNOT change

g = Gui()
g.title(
    "Brian's Homework Wk 4: Python's Impression of Picasso's Brick Factory at Tortosa"
)

# canvas is the drawing area
canvas = g.ca(width=CANVAS_WIDTH, height=CANVAS_HEIGHT)
main()
g.mainloop()
import math
import sys

from PyQt5 import QtWidgets

import Gui

# main entry point
if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    gui = Gui.Gui()
    sys.exit(app.exec_())
def main():
    # graphing variables
    fileName = "files/input100.txt"
    algoIndex = 4
    showAllEdges = False
    showWeights = True

    # create user input gui
    gui = Gui.Gui()
    gui.guiCreate()
    fileName = "files/" + gui.guiArray[0]
    algoIndex = gui.guiArray[1]
    showAllEdges = gui.guiArray[2]
    showWeights = gui.guiArray[3]

    # read input file
    fileObj = File(fileName)
    fileObj.readFile()

    # apply algo
    algoObj = importAlgo(algoIndex)
    selectedPath = algoObj.runAlgorithm(
        fileObj.graph, fileObj.nodesCount, fileObj.startNode)

    # print selected path
    printLine()
    print("Selected Edges:")
    for pathI, pathJ in selectedPath:
        print("(", pathI, "->", pathJ, ") :\t", fileObj.graph[pathI][pathJ])
    # print(selectedPath)

    printLine()
    print("Total Edge Cost: %0.2f" % calculateCost(
        selectedPath, fileObj.graph, fileObj.nodesCount))

    # display local clustering coefficient
    localClusterVal = clusterCoefficient(fileObj)
    printLine()
    print("Clustering Coefficient: %0.2f" % localClusterVal)

    # plot axis
    fig, ax = plt.subplots()
    fig.add_subplot(111)
    ax.axis((0, fileObj.maxXY[0], 0, fileObj.maxXY[1]))

    # add nodes and edges
    G = nx.Graph()
    node_edge_color, node_edge_width = addNodes(G, fileObj)
    edge_width = addEdges(G, fileObj, selectedPath, showAllEdges)

    # set position and edge variables
    pos = nx.get_node_attributes(G, 'pos')
    edges = G.edges()
    edge_color = [G[u][v]['color'] for u, v in edges]

    # show edge weights if variable true
    if showWeights:
        labels = nx.get_edge_attributes(G, 'weight')
        nx.draw_networkx_edge_labels(
            G, pos, edge_labels=labels, font_size=6, alpha=0.4, font_weight=0.1, label_pos=0.5)

    # draw the graph with desired attributes
    nx.draw(G, pos, with_labels=True, node_size=140, font_size=7,
            node_color='#ccccff', linewidths=node_edge_width, edgecolors=node_edge_color, width=edge_width, edge_color=edge_color)

    # display graph screen
    plt.show()
Ejemplo n.º 19
0
 def open_window(self):
     #open the GUI window!
     gui = Gui(self)
Ejemplo n.º 20
0
def main():
    """
    Create a Gui object and calls the run method inside of it
    """
    gui = Gui()
    gui.run()
Ejemplo n.º 21
0
def main():

    # randomize values in memory and create memory with size 1024 bits
    random.seed(17)
    memory = [
        random.randrange(0, mem_size // block_size)
        for i in range(mem_size // block_size)
    ]

    # power of 2 cache size [8, 16, 32, 64, 128, 256, 512, 1024]
    cache_sizes = [2**i for i in range(3, math.floor(math.log2(mem_size)) + 1)]

    times = []
    hit_rates = []
    compulsories = []
    capacities = []

    # for every value in cache_sizes, calculate and record hits, misses and time taken
    for cache_size in cache_sizes:
        cache = [-1 for i in range(cache_size // block_size)]
        returnVal = computeHit(memory, cache)
        times.append(returnVal[0])
        hit_rates.append(returnVal[1])
        compulsories.append(returnVal[2])
        capacities.append(returnVal[3])

    # for every cache size, print calculated results
    print("----------------------------------------")
    for i in range(len(cache_sizes)):
        print("Cache Size:\t\t %d" % cache_sizes[i])
        print("Approximate Hit Time:\t %d ms" % times[i])
        print("Hit Rate Percentage:\t %0.2f%%" %
              (hit_rates[i] / len(memory) * 100))
        print("Miss Rate Percentage:\t %0.2f%%" %
              (100 - (hit_rates[i] / len(memory) * 100)))
        print("Compulsory Misses:\t %0.2f%%" %
              (compulsories[i] / len(memory) * 100))
        print("Capacity Misses:\t %0.2f%%" %
              (capacities[i] / len(memory) * 100))
        print()

    # plot 3 graphs
    displayGraph(times, hit_rates, compulsories, capacities, cache_sizes,
                 memory)

    # create gui and ask memory and cache size
    gui = Gui.Gui()
    gui.guiCreate()
    x = gui.answer[0]
    y = gui.answer[1]

    # compute answer for user provided values
    random.seed(17)
    memory = [
        random.randrange(0, x // block_size) for i in range(x // block_size)
    ]
    cache = [-1 for i in range(y // block_size)]
    returnVal = computeHit(memory, cache)
    print("----------------------------------------")
    print("Cache Size:\t\t %d" % y)
    print("Memory Size:\t\t %d" % x)
    print("Approximate Hit Time:\t %d ms" % returnVal[0])
    print("Hit Rate Percentage:\t %0.2f%%" %
          (returnVal[1] / len(memory) * 100))
    print("Miss Rate Percentage:\t %0.2f%%" %
          (100 - returnVal[1] / len(memory) * 100))
    print("Compulsory Misses:\t %0.2f%%" % (returnVal[2] / len(memory) * 100))
    print("Capacity Misses:\t %0.2f%%" % (returnVal[3] / len(memory) * 100))
    print()
Ejemplo n.º 22
0
# !python3
# -*- coding: utf-8 -*-

import multiprocessing
import processes
from Browser import Browser
import Gui

if __name__ == "__main__":
    multiprocessing.freeze_support()
    tasks = multiprocessing.Queue()
    threads = [processes.DownloadWorker(tasks), processes.DownloadWorker(tasks)]
    for thread in threads:
        thread.daemon = True
        thread.start()
    browser = Browser()
    Gui.Gui(browser, tasks).mainloop()
Ejemplo n.º 23
0
def main():
    try:
        calculator = Gui.Gui()
    except:
        print("Error in gui generation")
Ejemplo n.º 24
0
def main():
    game = Gui()
Ejemplo n.º 25
0
import tkinter as tk
import Bank
import Gui

a = Bank.Account(name='mishu1', balance=1250, num='12345')
b = Bank.Account(name='mishu2', balance=700, num='58304')
c = Bank.Account(name='mishu3', balance=2150, num='10385')
a.deposit(500)

root = tk.Tk()
root.geometry('300x450')
main_gui = Gui.Gui(tk, root=root)
main_gui.top.add_accounts(accounts=[a, b, c])
main_gui.show()
Ejemplo n.º 26
0
import GenerateurMotDePasse

from sys import argv

import Gui

if __name__ == "__main__":
    interfaceGraphique = Gui.Gui()
    interfaceGraphique.exec()
Ejemplo n.º 27
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import locale, urllib2, re
import logging
locale.setlocale(locale.LC_ALL, '')
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
logging.getLogger("tshark.runtime").setLevel(logging.ERROR)

import wx
from Gui import *

if __name__ == '__main__':
    app = wx.App()
    guiHandler = Gui(None, title='Analizator bezpieczeństwa sieci')
    app.MainLoop()

#ify żeby tyldy nie dopisywało
#ify żeby nie podwajało **ip**ip**ip*****ip**

#service smbd stop & service apache2 stop & killall dnsmasq &  mitmf -i eth0 --spoof --arp --target 192.168.0.113 --gateway 192.168.0.1 --inject --js-url http://haks.pl/pliki/net.js

#dodać debug
#dodać poodle
Ejemplo n.º 28
0
 def __init__(self):
     self.gui = Gui(self)
Ejemplo n.º 29
0
from tkinter import Tk
from Gui import *

root = Tk()
app = Gui(root)  # Initialize our GUI

w = 400  # width for the window
h = 100  # height for the window

# get screen width and height
ws = app.master.winfo_screenwidth()  # width of the screen
hs = app.master.winfo_screenheight()  # height of the screen

# calculate x and y coordinates for the Tk root window
x = (ws / 2) - (w / 2)
y = (hs / 2) - (h / 2)

# set the dimensions of the screen
app.master.geometry('%dx%d+%d+%d' % (w, h, x, y))
app.master.mainloop()
Ejemplo n.º 30
0
    draw_tree_cluster(0, 0, 50)
    draw_tree_cluster(-40, -30, 65)
    draw_tree_cluster(60, -120, 120)
    draw_simple_tree(-80, -150, 140)
    draw_simple_tree(-100, -180, 160)


#####################################################################
#
# DO NOT CHANGE ANYTHING BELOW THIS LINE
#
#####################################################################

# Setup the canvas -- canvas is the drawing area
# Note that 'win' and 'canvas' are GLOBAL VARIABLES in this program
win = Gui.Gui()
win.title('Playing around with Gui')
canvas = win.ca(width=CANVAS_WIDTH, height=CANVAS_HEIGHT, bg='gray32')

# run the main function
main()

# show the window
win.mainloop()

# Here are some colors you can use: 'white', 'gray', 'black', 'red',
# 'green', 'blue', 'cyan', 'yellow', 'magenta', 'brown', 'darkgreen'
# Hundreds of colors here: http://tmml.sourceforge.net/doc/tk/colors.html
# I started this assignment by first imagining what I wanted my landscape
# drawing to be. When I saw the tree.py file, I knew exactly what I wanted to
# draw; some UFO's flying over a small town. Next, I had to figure out how I