Getting Started with Quickly
With the user interface complete, now let's write the search_for_term handler that performs the search. To edit your program's code, simply use the edit command in the terminal:
quickly edit
This will fire up each of your source files in your project into the default Ubuntu text editor, gedit. A number of different source files will load, but most of the action happens in the myapp file. This is the main Python program that is executed when you run quickly run.
The code you need to write to take the term entered into the search box and search Google with it is pretty simple, and you can use the webbrowser Python module to help. In the myapp file, after the import gtk line add: import webbrowser.
This imports the webbrowser Python module, which loads URLs into the system's default Web browser.
Now, scroll down, and after the on_destroy handler, add the following after the gtk.main_quit() line:
def search_for_term(self, widget, data=None):
"""Search for the term entered"""
searchurl = "http://www.google.com/#hl=en&source=hp&q="
searchterm = searchurl + widget.get_text()
webbrowser.open_new_tab(searchterm)
Here, you add the search_for_term handler, and it has three arguments that are passed to it:
self: all class methods are passed self, this is normal Python.
widget: this is a reference to the widget that called the handler. You can use this to get information from the text entry widget.
data=None: when you call a handler, you can pass it additional data if you like, but you can ignore this for this example.
When this handler runs, first construct the final search term by concatenating “http://www.google.com/#hl=en&source=hp&q=” and the content that was typed into the search box. To get this content, use the widget that was passed to the handler automatically. This is a reference to the text entry widget and can be used to run any of the methods that are part of the gtk.Entry text entry widget. One such method available is get_text(), which simply returns the text that was entered. As such, concatenate this with the Google URL, and you now have a complete URL you can pass to the Web browser. For example, if you typed in “chickens”, the full URL would be “http://www.google.com/#hl=en&source=hp&q=chickens”.
To pass the URL to the browser, use the webbrowser module and its open_new_tab() method that opens a new tab with the URL that you pass it.
With the code complete, let's run it to double-check that everything works:
quickly run
You now should see something similar to Figure 4 in which you can type some text, press Enter and see the results in your browser. If you see some errors in your terminal, be sure to double-check that you typed in everything correctly.
Quickly is an incredibly simple and powerful tool for generating applications, and I barely have scratched the surface of what is possible with it. You can find out more about using Quickly by visiting wiki.ubuntu.com/Quickly.
Jono Bacon is the Ubuntu Community Manager at Canonical, author of The Art Of Community published by O'Reilly, founder of the Community Leadership Summit and co-presenter on Shot Of Jaq and FLOSSWeekly.
- « first
- ‹ previous
- 1
- 2
- 3
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
Web Development News
Developer Poll
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
| Introduction to MapReduce with Hadoop on Linux | Jun 05, 2013 |
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- Linux Systems Administrator
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Validate an E-Mail Address with PHP, the Right Way
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Introduction to MapReduce with Hadoop on Linux
- Web & UI Developer (JavaScript & j Query)









2 hours 29 min ago
2 hours 55 min ago
5 hours 23 min ago
5 hours 57 min ago
5 hours 58 min ago
5 hours 58 min ago
6 hours 1 min ago
6 hours 2 min ago
6 hours 3 min ago
6 hours 4 min ago