0% encontró este documento útil (0 votos)
491 vistas6 páginas

GUI con Python usando VisualWx

Así que aquí estoy tratando de enseñar algo que estoy cultivando. Yo también recién empiezo en el uso de esta herramienta así que veremos que tal sale y comente que tal le parece, este tutorial es para trabajar en Windows porque no hay una versión de Visualwx para GNU/Linux.

Cargado por

Aprender Libre
Derechos de autor
© Attribution Non-Commercial (BY-NC)
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como PDF, TXT o lee en línea desde Scribd
0% encontró este documento útil (0 votos)
491 vistas6 páginas

GUI con Python usando VisualWx

Así que aquí estoy tratando de enseñar algo que estoy cultivando. Yo también recién empiezo en el uso de esta herramienta así que veremos que tal sale y comente que tal le parece, este tutorial es para trabajar en Windows porque no hay una versión de Visualwx para GNU/Linux.

Cargado por

Aprender Libre
Derechos de autor
© Attribution Non-Commercial (BY-NC)
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como PDF, TXT o lee en línea desde Scribd

Generated by Foxit PDF Creator Foxit Software [Link] For evaluation only.

Programando GUI de forma fcil en Python con un RAD Este es mi primer post, es algo que quera hacer desde hace tiempo ya que no encontraba informacin sobre el uso de esta herramienta en espaol (Visualwx). As que aqu estoy tratando de ensear algo que estoy cultivando. Yo tambin recin empiezo en el uso de esta herramienta as que veremos que tal sale y comente que tal le parece, este tutorial es para trabajar en Windows porque no hay una versin de Visualwx para GNU/Linux. Lo primero descargar e instalar Python, la ultima versin, desde su Web oficial, si quieren saber que es aqu. Es necesario que ya conozcan la sintaxis de este lenguaje, sino lean este tutorial muy bueno hecho por el propio autor del Lenguaje. Luego hay que descarga e instalar las wxPython desde aqu, es una herramienta que sirve para construir GUI. Por ultimo descargar e instalar VisualWx, la ultima versin desde aqu. Empezando Una vez instalado ejecutamos el RAD y tendremos algo como esto.

Vamos al men File y seleccionamos New Project, aparecer una ventanita donde se puede seleccionar los diferentes tipos de proyectos que deseamos hacer, son platillas que ya estn definidas y que nos ahorran la tarea. En este ejemplo seleccionare WX_SDI_Python, que aadir un wxFrame por defecto. Hacemos doble clic en [Link] y veremos nuestra primera ventanita en tiempo de diseo. La imagen se vera as

Tutorial GUI con Python por Julio_C

Generated by Foxit PDF Creator Foxit Software [Link] For evaluation only.

Ahora a ponerle un titulo, vamos a las propiedades de la ventana, para esto seleccionen este wxFrame y vayan a Properties en el lado inferior derecho

Dar doble clic en la parte blanca y se vera una ventanita donde escribirn el titulo de la ventana. Yo pondre mi ventana . Ahora regresamos a nuestro wxFrame, necesitamos agregar algunos wxWidgets. Seleccionamos Control y agregaremos un Static Text, que vendra a ser algo como un Label en Visual Basic.

Tutorial GUI con Python por Julio_C

Generated by Foxit PDF Creator Foxit Software [Link] For evaluation only.

Le hacemos doble clic y ya estar en nuestra ventana, por defecto se ubica en la posicin (0,0)

Ahora modificamos sus propiedades agregandole texto, vamos a Properties y en la propiedad Text doble clic, agregamos Saludo:. De la misma forma agregamos un Edit text y luego un Button. En este ejemplo lo que haremos ser; que al pulsar sobre el Botn nos muestre un saludo en la caja de texto. Tengo que recordar que estos wxWidgets son clases y que pueden ver el nombre de la clase en la ventan de propiedades. Al final nos debe quedar as, con algunas propiedades modificadas.

Tutorial GUI con Python por Julio_C

Generated by Foxit PDF Creator Foxit Software [Link] For evaluation only.

Ahora vamos al cdigo, como algunos se habrn dado cuenta, los mas distrados no. Hay una pestaa de cdigo pitn al lado de la de diseo solo que en la parte inferior de nuestra ventana.

En esta ventana esta el cdigo ya generado por VisualWx, que realmente ahorra mucho el trabajo. Bien nosotros agregaremos algo de cdigo, como saben hay que asignar los eventos a las funciones con wxWidgets en Python, pero aqu los haremos mas corto. Regresamos a la ventana de diseo y seleccionamos nuestro botn, luego en la ventana de propiedades hay una pestaa de eventos, al seleccionarlo se muestran unas letras debajo seleccionen la letra E, que corresponde a los eventos de los componentes y activamos el check de EVT_BUTTON

Tutorial GUI con Python por Julio_C

Generated by Foxit PDF Creator Foxit Software [Link] For evaluation only.

Luego regresamos a la ventana de cdigo y buscamos esta lnea.

Como ven el evento ya se ha creado, y asignado al boton. Ahora hay que agregar cdigo donde dice con comentarios #add your code here. Borramos la lnea donde dice return y escribimos. [Link] ("Hola a todos") Explicamos. Self corresponde a la instancia sobre la que trabajamos es decir a la vetanita, tx4c hace referencia al objeto que se creo, derivado de la clase wxTextCtrl y su propiedad SetValue, que en este caso recibe el parmetro de una cadena string Hola mundo. Ahora estamos listos. Ejecutamos la aplicacin desde el men Build Run o solo presionamos F5. Ya esta!!

Tutorial GUI con Python por Julio_C

Generated by Foxit PDF Creator Foxit Software [Link] For evaluation only.

Espero que haya sido til. Esperen la parte 2 de este tutorial donde mostrare el uso de ms wxWidgets usando VisualWx. Pueden compartir este Tutorial, pero por favor srvanse mencionar las fuentes. Saludos!

Tutorial GUI con Python por Julio_C

Common questions

Con tecnología de IA

Some challenges include the potential learning curve associated with understanding both the Python language and the nuances of wxWidgets classes, which demand a sound comprehension of event-driven programming. However, the benefits, as highlighted in the tutorial, include a simplified development process through visual design and automatic code generation, which can significantly expedite development cycles. Additionally, using wxPython with Visualwx enhances GUI fidelity with cross-platform capabilities, leveraging the mature widget set provided by wxWidgets .

Visualwx offers a visual interface for managing wxWidgets properties, where users can adjust attributes such as positions, sizes, labels, and event bindings through a straightforward properties pane. This management capability is crucial as it allows developers to tweak GUI appearance and behavior without diving into the code base, enabling rapid prototyping and iterative design. Effective management ensures that the component functionalities align with design specifications, improving user experience by maintaining consistency, clarity, and intuitive navigation across the user interface .

Visualwx provides a Rapid Application Development (RAD) environment tailored for Python GUI application creation, significantly easing the process by automatically generating the necessary code. As explained in the tutorial, it offers predefined templates for different types of projects, such as WX_SDI_Python, which include default components like wxFrame. This automation reduces the initial setup time and lowers the complexity barrier for creating functional GUIs. Additionally, integrating wxPython within Visualwx allows users to utilize wxWidgets, enabling them to design interfaces visually and manage properties through a straightforward interface .

The process involves several steps: starting with the installation of the necessary software, creating a new project in Visualwx with a predefined template, and designing the interface by adding components such as Static Text and Button using wxWidgets. The crucial role of wxWidgets in this process is that they serve as the building blocks or classes for creating GUI components. Users modify these widgets by setting properties through a properties window and assign functionality by handling events, such as configuring EVT_BUTTON for the button to trigger an event. The tutorial culminates with adding Python code in the event handler to display a message in the text control upon the button click, demonstrating the interactive capability made possible by wxWidgets .

Familiarity with Python's syntax is essential because Visualwx generates Python code that users must understand and potentially modify to implement specific functionalities. The tutorial emphasizes this as foundational, considering that manipulating widgets, handling events, and customizing logic require comprehension of basic Python commands and structures. Understanding the syntax ensures users can effectively read and write the code integral to GUI operations .

Using templates in Visualwx streamlines the initial phase of GUI development by providing predefined structures and components tailored to common application frameworks. This approach accelerates project setup, allowing developers to start with a functional layout, such as an SDI (Single Document Interface) application, with default elements like wxFrame in place. It results in a more efficient workflow, reduces the potential for initial errors, and helps beginners quickly engage with GUI component manipulation without dealing with setup complexities .

The setup begins with downloading and installing the latest version of Python from its official website, ensuring the user is familiar with Python's syntax. Next, wxPython needs to be downloaded and installed, which is essential for building GUIs with wxWidgets. After that, Visualwx should be downloaded and installed as the environment where the GUI development will take place. Each of these steps lays the foundation necessary for using Visualwx to efficiently create GUI applications by leveraging wxWidgets .

The tutorial instructs users to add a Static Text widget, comparable to a label in other GUI toolkits. Customization involves changing its default properties, specifically by double-clicking the text property and inputting a new label, such as 'Saludo:'. Customizing static text is significant because it provides context and labels adjacent interactive widgets, assisting users in understanding the input or interaction expected in the GUI, thereby enhancing usability and interface comprehension .

The tutorial utilizes wxTextCtrl as a text input/output area, allowing it to display dynamic content in response to user interactions, such as button clicks. The tutorial demonstrates assigning text via the SetValue method inside an event handler tied to a button press, which illustrates its role in displaying messages or taking user input. WxTextCtrl is critical as it provides the primary means of data entry and feedback within applications, essential for interactive and stateful GUIs .

The tutorial advises managing events by first selecting the GUI element—such as a button—in the design pane of Visualwx, accessing the properties window, and navigating to the events tab. Here, developers can associate GUI components with event handlers, such as enabling the EVT_BUTTON event for button clicks. Handling events is crucial in GUI applications as it defines interaction—the connection between user action and program response. Without event handling, GUI components would remain static and unresponsive to user inputs, rendering the interface ineffective .

Tutorial GUI con Python por Julio_C 
Programando GUI de forma fácil en Python con un RAD 
 
Este es mi primer post, es algo q
Tutorial GUI con Python por Julio_C 
 
 
Ahora a ponerle un titulo, vamos a las propiedades de la ventana, para esto 
selecci
Tutorial GUI con Python por Julio_C 
 
 
Le hacemos doble clic y ya estará en nuestra ventana, por defecto se ubica en la 
po
Tutorial GUI con Python por Julio_C 
 
 
Ahora vamos al código, como algunos se habrán dado cuenta, los mas distraídos no. 
H
Tutorial GUI con Python por Julio_C 
Luego regresamos a la ventana de código y buscamos esta línea. 
 
 
 
Como ven el evento
Tutorial GUI con Python por Julio_C 
 
 
Espero que haya sido útil. Esperen la parte 2 de este tutorial donde mostrare el uso

También podría gustarte