Beispiel #1
0
 def __init__(self):
     Application.__init__(self)
     self.blob_type = FileType(name = "Blob Document", suffix = "blob",
         #mac_creator = "BLBE", mac_type = "BLOB", # These are optional
     )
     self.file_type = self.blob_type
     self.blob_cursor = Cursor("blob.tiff")
Beispiel #2
0
    def __init__(self):
        Application.__init__(self)

        #define a file type for the app's files
        #this allows us to the app to recognize the files it can open
        self.file_type = FileType(name='Line Document', suffix='ln')

        #we can create new cursors to use in our views
        self.line_cursor = Cursor("crosshair.tiff")
Beispiel #3
0
def test():
	file = "grail_masked.tiff"
	#file = "spam_masked.tiff"
	image = Image(os.path.join(sys.path[0], file))
	cursor = Cursor(image)
	win = Window(title = "Image Cursor", width = 500, height = 400)
	view1 = TestDrawing(position = (20, 20), size = (100, 70), cursor = cursor)
	view2 = TestScrollableView(position = (140, 20), size = (200, 200),
		scrolling = 'hv')
	view2.cursor = cursor
	win.add(view1)
	win.place(view2, sticky = 'nsew')
	win.shrink_wrap((20, 20))
	win.show()
def _make_empty_cursor():
    global _empty_cursor
    if not _empty_cursor:
        from AppKit import NSCursor, NSImage, NSBitmapImageRep, NSDeviceRGBColorSpace
        from GUI import Cursor
        import sys
        if sys.version_info >= (3, 0):
            b = bytes([0])
        else:
            b = "\x00"
        d = b * 1024
        ns_bitmap = NSBitmapImageRep.alloc().\
            initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_\
            ((d, d, d, d, d), 16, 16, 8, 4, True, False, NSDeviceRGBColorSpace, 64, 32)
        ns_image = NSImage.alloc().initWithSize_((16, 16))
        ns_image.addRepresentation_(ns_bitmap)
        ns_cursor = NSCursor.alloc().initWithImage_hotSpot_(ns_image, (0, 0))
        _empty_cursor = Cursor._from_ns_cursor(ns_cursor)
        _empty_cursor._data = d
    return _empty_cursor
Beispiel #5
0
def _make_empty_cursor():
    global _empty_cursor
    if not _empty_cursor:
        from AppKit import NSCursor, NSImage, NSBitmapImageRep, NSDeviceRGBColorSpace
        from GUI import Cursor
        import sys
        if sys.version_info >= (3, 0):
            b = bytes([0])
        else:
            b = "\x00"
        d = b * 1024
        ns_bitmap = NSBitmapImageRep.alloc().\
         initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_\
         ((d, d, d, d, d), 16, 16, 8, 4, True, False, NSDeviceRGBColorSpace, 64, 32)
        ns_image = NSImage.alloc().initWithSize_((16, 16))
        ns_image.addRepresentation_(ns_bitmap)
        ns_cursor = NSCursor.alloc().initWithImage_hotSpot_(ns_image, (0, 0))
        _empty_cursor = Cursor._from_ns_cursor(ns_cursor)
        _empty_cursor._data = d
    return _empty_cursor
Beispiel #6
0
#		Python GUI - Standard Cursors - Gtk
#

from gtk import gdk
from GUI import Cursor

__all__ = [
    'arrow',
    'ibeam',
    'crosshair',
    'fist',
    'hand',
    'finger',
    'invisible',
]

arrow = Cursor._from_gtk_std_cursor(gdk.LEFT_PTR)
ibeam = Cursor._from_gtk_std_cursor(gdk.XTERM)
crosshair = Cursor._from_gtk_std_cursor(gdk.TCROSS)
fist = Cursor("cursors/fist.tiff")
hand = Cursor("cursors/hand.tiff")
finger = Cursor("cursors/finger.tiff")
invisible = Cursor._from_nothing()

del gdk
del Cursor


def empty_cursor():
    return invisible
Beispiel #7
0
def win_get_std_cursor(id):
    app = ui.GetApp()
    win_app = getattr(app, '_win_app', app)
    hcursor = win_app.LoadStandardCursor(id)
    return Cursor._from_win_cursor(hcursor)
Beispiel #8
0
    'finger',
    'invisible',
]


def win_get_std_cursor(id):
    app = ui.GetApp()
    win_app = getattr(app, '_win_app', app)
    hcursor = win_app.LoadStandardCursor(id)
    return Cursor._from_win_cursor(hcursor)


arrow = win_get_std_cursor(wc.IDC_ARROW)
ibeam = win_get_std_cursor(wc.IDC_IBEAM)
crosshair = win_get_std_cursor(wc.IDC_CROSS)
fist = Cursor("cursors/fist.tiff")
hand = Cursor("cursors/hand.tiff")
finger = win_get_std_cursor(wc.IDC_HAND)
invisible = Cursor._from_win_cursor(0)


def empty_cursor():
    return invisible


# Win32 only
wait = win_get_std_cursor(wc.IDC_WAIT)
up_arrow = win_get_std_cursor(wc.IDC_UPARROW)
size_all = win_get_std_cursor(wc.IDC_SIZEALL)
size_w_e = win_get_std_cursor(wc.IDC_SIZEWE)
size_n_s = win_get_std_cursor(wc.IDC_SIZENS)
Beispiel #9
0
class LineView(ScrollableView):

    cursors = {
        'eraser': Cursor("eraser.tiff"),
        'crosshair': Cursor("crosshair.tiff"),
        'fist': Cursor("fist.tiff")
    }

    def draw(self, canvas, update_rect):
        canvas.erase_rect(update_rect)
        canvas.fillcolor = red
        canvas.pencolor = black
        for line in self.model.lines:
            line.draw(canvas)

    def mouse_down(self, event):

        x, y = event.position
        line = self.model.find_line(x, y)

        if event.button is 'right':
            self.delete_lines()
        elif event.control:
            if line:
                self.drag_line(line, x, y)
        elif event.shift:
            if line:
                self.copy_line(line, x, y)
        else:
            self.draw_line(x, y)

    def copy_line(self, line, x, y):
        new_line = Line(x, y)
        new_line.copy(line)
        self.model.add_line(new_line)
        self.drag_line(new_line, x, y)

    def delete_lines(self):
        self.cursor = self.cursors['eraser']
        for event in self.track_mouse():
            x, y = event.position
            line = self.model.find_line(x, y)
            if line:
                self.model.remove_line(line)
        self.cursor = self.cursors['crosshair']

    def drag_line(self, line, x0, y0):
        self.cursor = self.cursors['fist']
        for event in self.track_mouse():
            x, y = event.position
            self.model.move_line(line, x - x0, y - y0)
            x0 = x
            y0 = y
        self.cursor = self.cursors['crosshair']

    def draw_line(self, x0, y0):
        line = Line(x0, y0)
        self.model.add_line(line)
        for event in self.track_mouse():
            x, y = event.position
            self.model.change_line(line, x, y)

    def line_changed(self, model, line):
        self.invalidate_rect(line.line)
Beispiel #10
0
            b = bytes([0])
        else:
            b = "\x00"
        d = b * 1024
        ns_bitmap = NSBitmapImageRep.alloc().\
         initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_\
         ((d, d, d, d, d), 16, 16, 8, 4, True, False, NSDeviceRGBColorSpace, 64, 32)
        ns_image = NSImage.alloc().initWithSize_((16, 16))
        ns_image.addRepresentation_(ns_bitmap)
        ns_cursor = NSCursor.alloc().initWithImage_hotSpot_(ns_image, (0, 0))
        _empty_cursor = Cursor._from_ns_cursor(ns_cursor)
        _empty_cursor._data = d
    return _empty_cursor


arrow = Cursor._from_ns_cursor(NSCursor.arrowCursor())
ibeam = Cursor._from_ns_cursor(NSCursor.IBeamCursor())
crosshair = Cursor._from_ns_cursor(NSCursor.crosshairCursor())
fist = Cursor._from_ns_cursor(NSCursor.closedHandCursor())
hand = Cursor._from_ns_cursor(NSCursor.openHandCursor())
finger = Cursor._from_ns_cursor(NSCursor.pointingHandCursor())
invisible = _make_empty_cursor()

mac_poof = Cursor._from_ns_cursor(NSCursor.disappearingItemCursor())

del NSCursor
del Cursor
del _make_empty_cursor


def empty_cursor():
#
#		Python GUI - Standard Cursors - Gtk
#

from gtk import gdk
from GUI import Cursor

__all__ = [
    'arrow',
    'ibeam', 
    'crosshair', 
    'fist', 
    'hand', 
    'finger', 
    'invisible', 
]

arrow = Cursor._from_gtk_std_cursor(gdk.LEFT_PTR)
ibeam = Cursor._from_gtk_std_cursor(gdk.XTERM)
crosshair = Cursor._from_gtk_std_cursor(gdk.TCROSS)
fist = Cursor("cursors/fist.tiff")
hand = Cursor("cursors/hand.tiff")
finger = Cursor("cursors/finger.tiff")
invisible = Cursor._from_nothing()

del gdk
del Cursor

def empty_cursor():
    return invisible
Beispiel #12
0
 def __init__(self, simbolo):
     self.simbolo = simbolo
     self.cursor = Cursor()
     self.alphabet = Alphabet([])
     self.er = ER([], self.alphabet)
     self.all()
Beispiel #13
0
class GUI:
    def __init__(self, simbolo):
        self.simbolo = simbolo
        self.cursor = Cursor()
        self.alphabet = Alphabet([])
        self.er = ER([], self.alphabet)
        self.all()

    #Metodo para establerzer tamaño de la ventana en windows

    def screen_sizeW(self):
        user32 = ctypes.windll.user32
        user32.SetProcessDPIAware()
        ancho, alto = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
        size = (ancho, alto)
        return size

    def all(self):

        display = pygame.display.set_mode((1920, 1080), pygame.RESIZABLE)
        pygame.display.set_caption("Automata")
        fuente = pygame.font.SysFont('Comic Sans MS', 15)
        # Cargar las images
        button = pygame.image.load(
            "C:\\Users\\marco\\OneDrive\\Documentos\\Automatas\\Proyecto1\\GUI\\Images\\button.png"
        )
        # Escalar imagenes
        button = pygame.transform.scale(button, (140, 75))
        # Asignacion de botones
        boton = ButtonP(button, button, 350, 20)
        # Texto para el boton
        prueba = fuente.render("Prueba", True, (0, 0, 0))

        #Prueba ventana
        while True:

            display.fill((100, 195, 199))
            for event in pygame.event.get():
                if event.type == pygame.MOUSEBUTTONDOWN:
                    if self.cursor.colliderect(boton.rect):
                        screenTK3 = Tk()
                        size = self.screen_sizeW()
                        screenTK3.geometry(
                            f"430x150+{int(size[0] / 2) - 230}+{int(size[1] / 2) - 100}"
                        )
                        screenTK3.title("Backpacker")
                        textC = StringVar(value="Ingrese el alfabeto")
                        labelC = Label(screenTK3,
                                       textvariable=textC).place(x=150, y=10)
                        texcT = StringVar(value="Ingrese la expresión regular")
                        labelT = Label(screenTK3,
                                       textvariable=texcT).place(x=150, y=50)
                        Cost_field = Entry(
                            screenTK3,
                            textvariable=self.alphabet.introSymbol,
                            width=25).place(x=150, y=30)
                        time_field = Entry(screenTK3,
                                           textvariable=self.er.symbols,
                                           width=25).place(x=150, y=70)
                        Button(screenTK3,
                               text="OK",
                               command=lambda: self.er.erValidate()).place(
                                   x=150, y=100)

                        screenTK3.mainloop()
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
            self.cursor.update()
            boton.update(display, self.cursor, prueba)
            pygame.display.update()
def win_get_std_cursor(id):
    app = ui.GetApp()
    win_app = getattr(app, '_win_app', app)
    hcursor = win_app.LoadStandardCursor(id)
    return Cursor._from_win_cursor(hcursor)
    'finger', 
    'invisible', 
]

def win_get_std_cursor(id):
    app = ui.GetApp()
    win_app = getattr(app, '_win_app', app)
    hcursor = win_app.LoadStandardCursor(id)
    return Cursor._from_win_cursor(hcursor)

arrow = win_get_std_cursor(wc.IDC_ARROW)
ibeam = win_get_std_cursor(wc.IDC_IBEAM)
crosshair = win_get_std_cursor(wc.IDC_CROSS)
fist = Cursor("cursors/fist.tiff")
hand = Cursor("cursors/hand.tiff")
finger = win_get_std_cursor(wc.IDC_HAND)
invisible = Cursor._from_win_cursor(0)

def empty_cursor():
    return invisible

# Win32 only
wait = win_get_std_cursor(wc.IDC_WAIT)
up_arrow = win_get_std_cursor(wc.IDC_UPARROW)
size_all = win_get_std_cursor(wc.IDC_SIZEALL)
size_w_e = win_get_std_cursor(wc.IDC_SIZEWE)
size_n_s = win_get_std_cursor(wc.IDC_SIZENS)
size_nw_se = win_get_std_cursor(wc.IDC_SIZENWSE)
size_ne_sw = win_get_std_cursor(wc.IDC_SIZENESW)

        if sys.version_info >= (3, 0):
            b = bytes([0])
        else:
            b = "\x00"
        d = b * 1024
        ns_bitmap = NSBitmapImageRep.alloc().\
            initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_\
            ((d, d, d, d, d), 16, 16, 8, 4, True, False, NSDeviceRGBColorSpace, 64, 32)
        ns_image = NSImage.alloc().initWithSize_((16, 16))
        ns_image.addRepresentation_(ns_bitmap)
        ns_cursor = NSCursor.alloc().initWithImage_hotSpot_(ns_image, (0, 0))
        _empty_cursor = Cursor._from_ns_cursor(ns_cursor)
        _empty_cursor._data = d
    return _empty_cursor

arrow = Cursor._from_ns_cursor(NSCursor.arrowCursor())
ibeam = Cursor._from_ns_cursor(NSCursor.IBeamCursor())
crosshair = Cursor._from_ns_cursor(NSCursor.crosshairCursor())
fist = Cursor._from_ns_cursor(NSCursor.closedHandCursor())
hand = Cursor._from_ns_cursor(NSCursor.openHandCursor())
finger = Cursor._from_ns_cursor(NSCursor.pointingHandCursor())
invisible = _make_empty_cursor()

mac_poof = Cursor._from_ns_cursor(NSCursor.disappearingItemCursor())

del NSCursor
del Cursor
del _make_empty_cursor

def empty_cursor():
    return invisible