Most viewed recipes tagged "gui"http://code.activestate.com/recipes/tags/gui/views/2015-07-06T23:15:31-07:00ActiveState Code RecipesA Phone Book GUI Built in wxPython Connected To Database Using Data Grid View (Python) 2013-09-29T19:25:23-07:00toufic zaarourhttp://code.activestate.com/recipes/users/4187866/http://code.activestate.com/recipes/578676-a-phone-book-gui-built-in-wxpython-connected-to-da/ <p style="color: grey"> Python recipe 578676 by <a href="/recipes/users/4187866/">toufic zaarour</a> (<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/datagridview/">datagridview</a>, <a href="/recipes/tags/graphical/">graphical</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/interface/">interface</a>). </p> <p>this GUI as simple as it is explains some basic but important graphical database interfacing; "Add", "Edit","Delete","Search" and few others along with a data grid view. in order to work create an sqlite3 database as follows:</p> <p>data table : Phone, column 1 : ID, column 2 : name, column 3 : surname, column 4 : telephone.</p> <p>save the sqlite3 file as file.db in a folder called Data and place it in the same directory as your python script.</p> <p>if you want to create the sqlite3 database graphically use my previous post : <a href="http://code.activestate.com/recipes/578665-a-wxpython-gui-to-create-sqlite3-databases/" rel="nofollow">http://code.activestate.com/recipes/578665-a-wxpython-gui-to-create-sqlite3-databases/</a></p> <p>Also there is more: I did not use auto-number for 'id' because I also wanted to include in the code a renumbering script.</p> <p>I am pleased to receive all the suggestions and improvements on this site or to my e-mail directly if this is convenient to you.</p> <p>note: if you don't like the database table name, and columns name create your own but make sure to change them in the code as well! in the end life is great! remember that!</p> Run asynchronous tasks using coroutines (Python) 2010-08-06T16:16:20-07:00Arnau Sanchezhttp://code.activestate.com/recipes/users/4173270/http://code.activestate.com/recipes/577129-run-asynchronous-tasks-using-coroutines/ <p style="color: grey"> Python recipe 577129 by <a href="/recipes/users/4173270/">Arnau Sanchez</a> (<a href="/recipes/tags/coroutine/">coroutine</a>, <a href="/recipes/tags/event/">event</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/gobject/">gobject</a>, <a href="/recipes/tags/gtk/">gtk</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/nonblocking/">nonblocking</a>, <a href="/recipes/tags/pygtk/">pygtk</a>). Revision 20. </p> <p>This recipe shows a simple, transparent (and hopefully pythonic) way of running asynchronous tasks when writing a event-driven application (i.e. GUI). The aim is to allow a programmer to write time-consuming functions (usually IO-bound, but not only) with sequential-looking code, instead of scattering the logic over a bunch of callbacks. We will take advantage of the coroutines introduced in Python 2.5 (see <a href="http://www.python.org/dev/peps/pep-0342" rel="nofollow">http://www.python.org/dev/peps/pep-0342</a>). </p> <p>The goal: wouldn't it be great if we could write something like this?</p> <pre class="prettyprint"><code>def myjob(entry, arg1, arg2, arg3): result1 = function_that_takes_eons_to_complete(arg1, arg2) result2 = another_function_that_downloads_a_big_really_big_file(result1, arg3) entry.set_text("The result is: %d" % result2) def on_start_button___clicked(button, entry): myjob(entry, 1, 2, 3) ... gtk.main() </code></pre> <p>Indeed, but we can't! The GUI will hang until the job is done and the user will be rightfully angry. Coroutines to the rescue: the absolute minimal change we can make to this code is transforming <em>myjob</em> into a coroutine and yield every time we do blocking stuff:</p> <pre class="prettyprint"><code>def myjob(entry, arg1, arg2, arg3): result1 = yield some_task(arg1, arg2) result2 = yield some_other_task(result1, arg3) entry.set_text("The result is: %d" % result2) def on_start__clicked(button, entry): start_job(myjob(entry, 1, 2, 3)) </code></pre> <p><em>some_task</em> and <em>some_other_task</em> are here the asynchronous implementation of the sequential tasks used in the first fragment, and <em>start_job</em> the wrapper around the coroutine. Note that we still have to implement non-blocking versions of the tasks, but they are usually pretty generic (wait some time, download a file, ...) and can be re-used. If you happen to have a CPU-bound function or even a IO-bound code you cannot split (<em>urllib2</em> anyone?), you can always use a generic threaded task (granted, the whole point of using co-routines should be avoiding threads, but there is no alternative here).</p> <p>At the end, all the plumbing we need to make it work is just 1 function: <em>start_job</em> (wrapper around the job to manage the flow of the coroutine). The rest of the code -two asynchronous tasks (<em>sleep_task</em>, <em>threaded_task</em>) and a demo app- are shown solely as an example.</p> A wxPython GUI To Create Sqlite3 Databases (Python) 2013-09-18T23:05:51-07:00toufic zaarourhttp://code.activestate.com/recipes/users/4187866/http://code.activestate.com/recipes/578665-a-wxpython-gui-to-create-sqlite3-databases/ <p style="color: grey"> Python recipe 578665 by <a href="/recipes/users/4187866/">toufic zaarour</a> (<a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/sqlite/">sqlite</a>, <a href="/recipes/tags/wxpython/">wxpython</a>). Revision 2. </p> <p>A GUI built around wxPython in a way that will allow you to add to this application other forms and functionalities. The main DialogBox is to create,in a fast way, Sqlite3 databases that are used for web or applications development. In order to work properly, save the script in a separate directory.There is also more; each time you create a database a text file named "CreationLog.txt" will be created (for the first time you use the application or if it is not there) and updated, describing when and where was your database created and with what SQL query. I am pleased to receive all the suggestions and improvements on this site or to my e-mail directly if this is convenient to you.</p> All in one Area Calculator (Python) 2014-07-03T09:16:14-07:00karimhttp://code.activestate.com/recipes/users/4190244/http://code.activestate.com/recipes/578901-all-in-one-area-calculator/ <p style="color: grey"> Python recipe 578901 by <a href="/recipes/users/4190244/">karim</a> (<a href="/recipes/tags/calculator/">calculator</a>, <a href="/recipes/tags/circlearea/">circlearea</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/python3/">python3</a>, <a href="/recipes/tags/tkinter/">tkinter</a>, <a href="/recipes/tags/tranglearea/">tranglearea</a>, <a href="/recipes/tags/trianglearea/">trianglearea</a>). Revision 2. </p> <p>Its a python 3 based All in one Area Calculator.you can calculate Area of Rectangle,Area of Triangle and Area of Circle</p> Using proxy connection for QWebView (Python) 2009-10-02T02:32:51-07:00Keisuke URAGOhttp://code.activestate.com/recipes/users/668964/http://code.activestate.com/recipes/576921-using-proxy-connection-for-qwebview/ <p style="color: grey"> Python recipe 576921 by <a href="/recipes/users/668964/">Keisuke URAGO</a> (<a href="/recipes/tags/browser/">browser</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/pyqt/">pyqt</a>, <a href="/recipes/tags/qt4/">qt4</a>, <a href="/recipes/tags/web/">web</a>). Revision 4. </p> <p>QWebView is powerful web browser. This script can use a http-proxy host. Log file name is minibrowser.log in same directory.</p> Delete a Gtk.TreeView row (Python) 2013-11-27T13:59:58-08:00Anonimistahttp://code.activestate.com/recipes/users/4188571/http://code.activestate.com/recipes/578773-delete-a-gtktreeview-row/ <p style="color: grey"> Python recipe 578773 by <a href="/recipes/users/4188571/">Anonimista</a> (<a href="/recipes/tags/gtk/">gtk</a>, <a href="/recipes/tags/gui/">gui</a>). </p> <p>Delete a Gtk.TreeView row</p> Accordion Widget (Tkinter) (Python) 2014-07-18T11:39:51-07:00Peter Mojeikohttp://code.activestate.com/recipes/users/4190241/http://code.activestate.com/recipes/578911-accordion-widget-tkinter/ <p style="color: grey"> Python recipe 578911 by <a href="/recipes/users/4190241/">Peter Mojeiko</a> (<a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). </p> <p>An expanding/collapsing widget for Tkinter.</p> <p>usage:</p> <pre class="prettyprint"><code>from accordion import Accordion, Chord root = Tk() accordion = Accordion(root) accordion.pack() chord1 = Chord(accordion, title='Chord') # create widgets and give them chord1 as parent accordion.append_chords([chord1]) root.mainloop() </code></pre> <p>There's a more detailed example at the bottom of the file.</p> Multiplication Table (Python) 2009-07-22T15:25:39-07:00joedaviscpahttp://code.activestate.com/recipes/users/4170361/http://code.activestate.com/recipes/576851-multiplication-table/ <p style="color: grey"> Python recipe 576851 by <a href="/recipes/users/4170361/">joedaviscpa</a> (<a href="/recipes/tags/binding_widgets/">binding_widgets</a>, <a href="/recipes/tags/event_handler_arguments/">event_handler_arguments</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 4. </p> <p>This is a GUI multiplication table. The labels and buttons are created in loops, yet each button has an associated value. </p> Directory Size (GUI) (Python) 2011-02-09T13:47:54-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577567-directory-size-gui/ <p style="color: grey"> Python recipe 577567 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/application/">application</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/sizeof/">sizeof</a>, <a href="/recipes/tags/tree/">tree</a>). Revision 2. </p> <p>Have you ever wanted to find out how much room a particular directory was taking up on your hard drive? A roommate of mine in college was having trouble keeping track of where his hard drive space is going, so the following program provided a solution that allows a brief overview of a directory's size along with all of its children. A tree view is created using tkinter and is populated with the directory's name, cumulative size, immediate total file size, and full path. The search button is disabled during a search, and the directory listing with its children is automatically updated.</p> bookmarks browser for firefox (Python) 2015-07-06T23:15:31-07:00Anton Vredegoorhttp://code.activestate.com/recipes/users/2667360/http://code.activestate.com/recipes/579077-bookmarks-browser-for-firefox/ <p style="color: grey"> Python recipe 579077 by <a href="/recipes/users/2667360/">Anton Vredegoor</a> (<a href="/recipes/tags/bookmarks/">bookmarks</a>, <a href="/recipes/tags/firefox/">firefox</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). </p> <p>a small tkinter gui to browse the .json type bookmark files firefox automatically generates each day. It's meant to be run from a terminal. If a tree item is doubleclicked it prints the uri.</p> List MySql databases in a Gtk.TreeView (Python) 2013-11-27T14:03:21-08:00Anonimistahttp://code.activestate.com/recipes/users/4188571/http://code.activestate.com/recipes/578774-list-mysql-databases-in-a-gtktreeview/ <p style="color: grey"> Python recipe 578774 by <a href="/recipes/users/4188571/">Anonimista</a> (<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/gtk/">gtk</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/mysqldb/">mysqldb</a>, <a href="/recipes/tags/user_interface/">user_interface</a>). </p> <p>List MySql databases in a Gtk.TreeView</p> Use Gtk.TreeView to browse MySql databases (Python) 2013-11-27T14:06:20-08:00Anonimistahttp://code.activestate.com/recipes/users/4188571/http://code.activestate.com/recipes/578775-use-gtktreeview-to-browse-mysql-databases/ <p style="color: grey"> Python recipe 578775 by <a href="/recipes/users/4188571/">Anonimista</a> (<a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/mysqldb/">mysqldb</a>, <a href="/recipes/tags/user_interface/">user_interface</a>). </p> <p>Use Gtk.TreeView to browse MySql database structure from database to tables and views and to columns</p> Directory Pruner 2 (Python) 2011-04-05T01:37:14-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577633-directory-pruner-2/ <p style="color: grey"> Python recipe 577633 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/delete/">delete</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/utility/">utility</a>). </p> <p>This program builds on work done in <a href="http://code.activestate.com/recipes/577632/">recipe 577632</a>, adds new options to the context menu, and experiments with threading the GUI. Directory Pruner 2 appear to work better on Windows 7 while Directory Pruner 1 (the non-threaded version) performs better on Windows XP. Those are the primary platforms on which the two programs have been tested. Please use these applications at your own risk.</p> <p>If you do not like something about this recipe and want to vote it down, please let everyone what you find fault with, how you would improve it, and an example of the code you would improve.</p> File Share Messenger 2.5 (Python) 2011-04-06T02:45:15-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577638-file-share-messenger-25/ <p style="color: grey"> Python recipe 577638 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/file_io/">file_io</a>, <a href="/recipes/tags/file_share/">file_share</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/messenger/">messenger</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/workaround/">workaround</a>). </p> <p>After writing the limited program shown in <a href="http://code.activestate.com/recipes/577637/">recipe 577637</a>, the following program was written with a better yet incompatible I/O system designed not to fill up a file share with many, separate files. This program had five revisions as outlined within the source code. To access settings within this program, use the "F2" key. Documentation may be accessed via the "F1" key (with future plans cut).</p> <p>If anyone wishes to comment or vote this recipe down, please provide your insight into the fault(s) of the program and provide a suggestion as to what solution you would implement to fix the problems.</p> edit dictionary values (possibly restrained) with Tkinter (Python) 2011-03-15T21:37:54-07:00s_h_a_i_ohttp://code.activestate.com/recipes/users/4177334/http://code.activestate.com/recipes/577611-edit-dictionary-values-possibly-restrained-with-tk/ <p style="color: grey"> Python recipe 577611 by <a href="/recipes/users/4177334/">s_h_a_i_o</a> (<a href="/recipes/tags/edit/">edit</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/in/">in</a>, <a href="/recipes/tags/options/">options</a>). </p> <p>The behaviour of applications sometimes depends on various parameters that can be chosen by the user through some GUI. Quite often, these parameters need take value in a predefined set. Parameters include for instance:</p> <ul> <li>The number of replications for a simulator.</li> <li>Dates of beginning/end of sample for time series access/plot.</li> <li>Log writing</li> </ul> <p>This recipe assumes that</p> <ul> <li>Such parameters are stored in a dictionary. Values in the dictionnary are used as initial values for the parameters.</li> <li>Values are "singleton", i.e non iterable (although they may be strings).</li> <li>When a value is a list instance, its content represent the set of possible values The recipe offers a simple way to edit the values in a Tkinter Frame, by adding proper widget to it (constrained value are menubutton while unconstrained values are edit widgets).</li> </ul> <p>This is done by the function apply(frame,dict,position), which adds to the Tkinter frame the necessary widgets to edit the dictionary dict. Widgets are placed using grid (hence the frame needs use grid() too) and span on two columns. topleft position (x,y) in grid is specified using position= (x,y,0,0)</p> Typing skills meter (Python) 2012-11-02T12:29:25-07:00Pierre Quentelhttp://code.activestate.com/recipes/users/1552957/http://code.activestate.com/recipes/578318-typing-skills-meter/ <p style="color: grey"> Python recipe 578318 by <a href="/recipes/users/1552957/">Pierre Quentel</a> (<a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/typing/">typing</a>). </p> <p>A Tkinter-based program that shows your typing skills (speed and error rate) in the form of a car dashboard</p> <p>The text to type is displayed in a text zone, the cursor and the dashboard needles progress as you type the letters. Text can be copied-pasted, or loaded from a file that users can store in the subfolder "texts"</p> <p>The interface language can be configured (in this version, only French-English, but easily extendable to other languages)</p> Directory Pruner 1 (Python) 2011-04-05T00:56:25-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577632-directory-pruner-1/ <p style="color: grey"> Python recipe 577632 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/delete/">delete</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/utility/">utility</a>). </p> <p>This program is an extension of <a href="http://code.activestate.com/recipes/577567/">recipe 577567</a> in that it not only allows one to find a directory's size but also remove files based on a context menu. The directory pruner has been used by my roommate to free up room on his hard drive and also by several friends that wished to remove games and other unnecessary program that were taking up their space. Right-click on found directories to review your options.</p> <p>If you wish to vote this recipe down, please post a comment at the bottom telling me how you would improve the utility.</p> Quiz Me 2.5 (main) (Python) 2011-01-09T21:14:04-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577525-quiz-me-25-main/ <p style="color: grey"> Python recipe 577525 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/program/">program</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/quiz/">quiz</a>). Revision 2. </p> <p>Before discovering <a href="http://quizlet.com/" rel="nofollow">http://quizlet.com/</a>, the following program was developed for running custom quizzes to help with studying for college courses. The program is not very advanced, but it works reasonably well for what it was designed to do. If the program were developed further, it would need greater capabilities than it currently has and would require a secondary system for actually creating the quizzes (currently, they are hand-typed). Quiz Me could be a starting point for anyone who wishes to actually write a program such as this and inspire others to write much better programs than what this recipe currently offers.</p> <p>This is the main entry point to the Quiz Me program. It creates the GUI context and sets the program up for automatic error logging. Experimental threading support is provided but unused in the program. Since the main application subclasses a frame, it can easily be embedded in another application without much difficulty. Quiz Me is entirely event based and has an event runner in the very last method shown here.</p> Music Downloader with Wx GUI! (Python) 2013-11-05T02:52:29-08:00Christian Careagahttp://code.activestate.com/recipes/users/4186639/http://code.activestate.com/recipes/578681-music-downloader-with-wx-gui/ <p style="color: grey"> Python recipe 578681 by <a href="/recipes/users/4186639/">Christian Careaga</a> (<a href="/recipes/tags/beautifulsoup/">beautifulsoup</a>, <a href="/recipes/tags/downloader/">downloader</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/music/">music</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/urllib/">urllib</a>, <a href="/recipes/tags/urllib2/">urllib2</a>, <a href="/recipes/tags/wxpyton/">wxpyton</a>). </p> <p>Just type in a song and the artist and the program will get the YouTube video, convert it to an mp3 then download it! It has a high quality function and a medium quality function and also the user can choose the directory and name they want the file to be saved to!</p> <p>It is the first time I've used threads and my second time with WxPython! I used BeautifulSoup for the scraping and I'm pretty familiar with that.just thought id share it with you guys and see if you have any feedback or suggestions!</p> <p>also you may get an error saying self.convhtml doesn't exist just wait then retry</p> <p>Here is a link to an screenshot:</p> <p><a href="http://adf.ly/XJaoU" rel="nofollow">http://adf.ly/XJaoU</a></p> <p>if you want you can checkout the Github page:</p> <p><a href="http://adf.ly/XGL6P" rel="nofollow">http://adf.ly/XGL6P</a></p> <p>also you will need to make a folder called Files and put a file called dir.txt and in the file write /Files. this is where the music will be downloaded to!</p> <p>I just made the .exe so you can just use that and its easier! Here: <a href="http://adf.ly/XRjRH" rel="nofollow">http://adf.ly/XRjRH</a></p> Patch/diff file viewer with highlighting (Python) 2010-10-29T10:48:15-07:00Anton Butanaevhttp://code.activestate.com/recipes/users/4175501/http://code.activestate.com/recipes/577436-patchdiff-file-viewer-with-highlighting/ <p style="color: grey"> Python recipe 577436 by <a href="/recipes/users/4175501/">Anton Butanaev</a> (<a href="/recipes/tags/cvs/">cvs</a>, <a href="/recipes/tags/diff/">diff</a>, <a href="/recipes/tags/git/">git</a>, <a href="/recipes/tags/gui/">gui</a>). Revision 4. </p> <p>diff shows difference in files in whole lines. Sometimes those lines are very similar, only one or two words changed. This script compares changed lines by characters and highlights actual differences in them.</p>