elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [Python + tkinter] Ayuda con marco de una ventana y sus botones
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Python + tkinter] Ayuda con marco de una ventana y sus botones  (Leído 10,806 veces)
darkweb64

Desconectado Desconectado

Mensajes: 17



Ver Perfil
[Python + tkinter] Ayuda con marco de una ventana y sus botones
« en: 7 Octubre 2015, 18:54 pm »

Buen día miembros del foro, necesito ayuda para quitar por completo los botones de minimizar, maximizar y cerrar de una ventana estándar en tkinter.
He logrado quitar el botón de maximizar y minimizar como muestro en el código de abajo.
Pero quiero mantener el borde para que se vea el título de la ventana sin ningún botón.

Código:
from tkinter import *

root = Tk()
root.title("Ventana con nombre del programa")
#root.overrideredirect(1) # No me sirve quita todo
root.attributes("-toolwindow",-1) # Solo permite el botón cerra en una ventana
root.mainloop()



« Última modificación: 7 Octubre 2015, 19:22 pm por darkweb64 » En línea

0roch1

Desconectado Desconectado

Mensajes: 123



Ver Perfil
Re: [Python + tkinter] Ayuda con marco de una ventana y sus botones
« Respuesta #1 en: 7 Octubre 2015, 19:11 pm »

¿En qué sistema operativo estás trabajando?


« Última modificación: 7 Octubre 2015, 19:15 pm por 0roch1 » En línea

darkweb64

Desconectado Desconectado

Mensajes: 17



Ver Perfil
Re: [Python + tkinter] Ayuda con marco de una ventana y sus botones
« Respuesta #2 en: 7 Octubre 2015, 19:21 pm »

Es para windows y uso python3.4
En línea

0roch1

Desconectado Desconectado

Mensajes: 123



Ver Perfil
Re: [Python + tkinter] Ayuda con marco de una ventana y sus botones
« Respuesta #3 en: 7 Octubre 2015, 20:00 pm »

Nunca lo he intentado pero esto es algo que se me ocurre por el momento.

Código
  1. __author__ = '0roch1'
  2. # -*- coding: utf-8 -*-
  3. try:
  4.    from Tkinter import * # Python2
  5. except ImportError:
  6.  
  7.    from tkinter import * # Python3
  8.  
  9. def __Cancel(event=None): pass
  10.  
  11. root = Tk()
  12. root.title("Título")
  13. root.resizable(0,0)
  14. root.attributes("-toolwindow",-1)
  15. root.protocol('WM_DELETE_WINDOW', __Cancel )
  16.  
  17. root.mainloop()
  18.  

Otra cosa que se pude hacer es utilizar
Código
  1. root.overrideredirect(1)
  2.  

y después agregar un borde a la ventana.
En línea

darkweb64

Desconectado Desconectado

Mensajes: 17



Ver Perfil
Re: [Python + tkinter] Ayuda con marco de una ventana y sus botones
« Respuesta #4 en: 7 Octubre 2015, 20:49 pm »

Gracias, lo probé y aunque no quita el botón cerrar de la barra lo anula, aunque me parece extraño que exista una forma para quitar el de maximizar y minimizar y no ese.
En línea

0roch1

Desconectado Desconectado

Mensajes: 123



Ver Perfil
Re: [Python + tkinter] Ayuda con marco de una ventana y sus botones
« Respuesta #5 en: 7 Octubre 2015, 21:14 pm »

No, no lo quita, decía que era posiblemente una forma, pensé que lo que te interesaba era que no cerraran la ventana pero más bien quieres quitarlo por diseño, no?.

Lo único que quieres quitar son los botones, dejar la barra de título y mantener el borde de la ventana?.
En línea

darkweb64

Desconectado Desconectado

Mensajes: 17



Ver Perfil
Re: [Python + tkinter] Ayuda con marco de una ventana y sus botones
« Respuesta #6 en: 7 Octubre 2015, 21:51 pm »

Sí, mantener la barra pero sin botones.
En línea

0roch1

Desconectado Desconectado

Mensajes: 123



Ver Perfil
Re: [Python + tkinter] Ayuda con marco de una ventana y sus botones
« Respuesta #7 en: 8 Octubre 2015, 20:58 pm »

¿Qué intentas hacer?

Esto te servirá?.

Código
  1. """
  2. Python Tkinter Splash Screen
  3.  
  4. This script holds the class SplashScreen, which is simply a window without
  5. the top bar/borders of a normal window.
  6.  
  7. The window width/height can be a factor based on the total screen dimensions
  8. or it can be actual dimensions in pixels. (Just edit the useFactor property)
  9.  
  10. Very simple to set up, just create an instance of SplashScreen, and use it as
  11. the parent to other widgets inside it.
  12.  
  13. www.sunjay-varma.com
  14. """
  15.  
  16. from Tkinter import *
  17.  
  18. class SplashScreen(Frame):
  19.    def __init__(self, master=None, width=0.8, height=0.6, useFactor=True):
  20.        Frame.__init__(self, master)
  21.        self.pack(side=TOP, fill=BOTH, expand=YES)
  22.  
  23.        # get screen width and height
  24.        ws = self.master.winfo_screenwidth()
  25.        hs = self.master.winfo_screenheight()
  26.        w = (useFactor and ws*width) or width
  27.        h = (useFactor and ws*height) or height
  28.        # calculate position x, y
  29.        x = (ws/2) - (w/2)
  30.        y = (hs/2) - (h/2)
  31.        self.master.geometry('%dx%d+%d+%d' % (w, h, x, y))
  32.  
  33.        self.master.overrideredirect(True)
  34.        self.lift()
  35.  
  36. if __name__ == '__main__':
  37.    root = Tk()
  38.  
  39.    sp = SplashScreen(root)
  40.    sp.config(bg="#3366ff")
  41.  
  42.    m = Label(sp, text="This is a test of the splash screen\n\n\nThis is only a test.\nwww.sunjay-varma.com")
  43.    m.pack(side=TOP, expand=YES)
  44.    m.config(bg="#3366ff", justify=CENTER, font=("calibri", 29))
  45.  
  46.    Button(sp, text="Press this button to kill the program", bg='red', command=root.destroy).pack(side=BOTTOM, fill=X)
  47.    root.mainloop()
  48.  
Fuente: http://code.activestate.com/recipes/577271-tkinter-splash-screen/


No sé si es posible hacer exactamente lo que pides.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
(Python/Tk) ocultar "marco ventana" tk
Scripting
tonilogar 2 6,177 Último mensaje 3 Diciembre 2009, 00:26 am
por tonilogar
Ayuda con Python, ftp y Tkinter
Scripting
Eirthur 1 3,928 Último mensaje 11 Mayo 2013, 03:56 am
por daryo
Ayuda botones Tkinter
Scripting
AlbertSerres 2 2,877 Último mensaje 23 Octubre 2013, 18:23 pm
por Eleкtro
[Python + tkinter] Ayuda con botón de una ventana y tecla enter
Scripting
darkweb64 3 6,106 Último mensaje 13 Mayo 2015, 23:10 pm
por tincopasan
[Python3 + tkinter] Ayuda ventanas en cascada tkinter
Scripting
darkweb64 2 3,563 Último mensaje 11 Diciembre 2015, 18:04 pm
por darkweb64
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines