Project

General

Profile

Interfaz » History » Version 2

Version 1 (ana gutierrez, 09/10/2024 05:22 PM) → Version 2/11 (ana gutierrez, 09/10/2024 05:29 PM)

h1. Interfaz



<pre><código de clase="ruby"> clase=&quot;python&quot;&gt;
# The Greeter import tkinter as tk

class
class Greeter
Aplicacion:
def initialize(name)
@name
__init__(self, root):
self.root
= name.capitalize
end

root
self.root.title(&quot;Blitz&quot;)
self.root.geometry(&quot;800x450&quot;)
self.root.resizable(0, 0)

# Cargar el logo
self.root.iconbitmap(&quot;resources/logo.ico&quot;)

# Cargar la imagen de fondo
self.imagen_fondo = tk.PhotoImage(file=&quot;resources/fondo1.png&quot;)

# Crear un Canvas para colocar la imagen de fondo
self.canvas = tk.Canvas(self.root, width=800, height=400)
self.canvas.pack(fill=&quot;both&quot;, expand=True)

# Colocar la imagen en el Canvas
self.canvas.create_image(0, 0, image=self.imagen_fondo, anchor=&quot;nw&quot;)

# Imágenes para los botones
self.imagen_central = tk.PhotoImage(file=&quot;resources/center.png&quot;)
self.imagen_arriba = tk.PhotoImage(file=&quot;resources/up.png&quot;)
self.imagen_abajo = tk.PhotoImage(file=&quot;resources/down.png&quot;)
self.imagen_izquierda = tk.PhotoImage(file=&quot;resources/left.png&quot;)
self.imagen_derecha = tk.PhotoImage(file=&quot;resources/right.png&quot;)
self.imagen_apagado = tk.PhotoImage(file=&quot;resources/off.png&quot;)


# Cuadro &quot;transparente&quot;
self.canvas.create_rectangle(50, 210, 230, 390, fill=&quot;#052D45&quot;, stipple=&quot;gray50&quot;, outline=&quot;&quot;)

self.crear_botones()

def salute crear_botones(self):
self.boton_central = tk.Button(self.root, image=self.imagen_central, borderwidth=0, highlightthickness=0, cursor=&quot;hand2&quot;)
self.canvas.create_window(140, 300, window=self.boton_central)

self.boton_arriba = tk.Button(self.root, image=self.imagen_arriba, borderwidth=0, highlightthickness=0, cursor=&quot;hand2&quot;)
self.canvas.create_window(140, 245, window=self.boton_arriba)

self.boton_abajo = tk.Button(self.root, image=self.imagen_abajo, borderwidth=0, highlightthickness=0, cursor=&quot;hand2&quot;)
self.canvas.create_window(140, 355, window=self.boton_abajo)

self.boton_izquierda = tk.Button(self.root, image=self.imagen_izquierda, borderwidth=0, highlightthickness=0, cursor=&quot;hand2&quot;)
self.canvas.create_window(85, 300, window=self.boton_izquierda)

self.boton_derecha = tk.Button(self.root, image=self.imagen_derecha, borderwidth=0, highlightthickness=0, cursor=&quot;hand2&quot;)
self.canvas.create_window(195, 300, window=self.boton_derecha)

self.boton_apagado = tk.Button(self.root, image=self.imagen_apagado, borderwidth=0, highlightthickness=0, cursor=&quot;hand2&quot;)
self.canvas.create_window(755, 400, window=self.boton_apagado)

if __name__ == &quot;__main__&quot;:

puts "Hello #{@name}!"
end
end
</código></pre>
root = tk.Tk()
app = Aplicacion(root)
root.mainloop()