Python Programming for Biology: Bioinformatics and Beyond



Download 7,75 Mb.
Pdf ko'rish
bet431/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   427   428   429   430   431   432   433   434   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

Python GUI examples

In this chapter we will give a simple introduction to the Python versions of the Tkinter and

Qt graphics systems. Such a task could fill a whole book, so for this chapter we will keep

things very simple and aim to give an impression of the basic principles and what kinds of




things  are  possible:  to  help  a  programmer  get  started,  rather  than  give  an  in-depth

description of every possible widget. The examples construct a simple graphical interface

for some of the biological sequence analysis that was discussed in

Chapter 11

. Indeed, we

will import functions defined there.

3

 We  will  only  show  a  few  of  the  more  basic  widget



types,  but  the  interface  will  be  functional.  The  same  basic  interface  will  be  constructed

using  both  Tkinter  and  Qt,  so  that  you  can  compare  and  contrast  the  differences.  There

might  be  a  more  elegant  way  of  handling  things  in  either  example,  but  we  have  tried  to

keep the equivalence reasonably close.

Compared  to  most  of  the  other  chapters,  the  reader  will  notice  that  the  examples  are

constructed by using classes, which generate a customised version of a graphical Python

object.  Whereas  in  most  of  the  examples  in  this  book  we  can  illustrate  the  principles  by

sticking  predominantly  to  simpler  Python  functions  (and  leave  it  to  the  programmer  to

decide whether to use classes), here for the GUI code we actively encourage using classes

from the outset. The reason for this is the high degree of interconnectivity and data sharing

that  goes  on  with  graphical  items  and  the  underlying  data  they  represent  or  manipulate.

Making a class for a graphical interface, which usually at least requires a subclass of a top-

level window, allows all of the component widgets to be automatically grouped. Also, it is

less sensitive to the order in which the code is written and minimises the arguments that

have  to  be  passed;  internal  functions  can  access  class  attributes  (variables  that  belong  to

the GUI object). A GUI can be written with functions alone, but it is harder work.

The  interfaces  that  form  the  examples  are  pictured  in

Figure  26.2

.  Each  example

consists of a single top-level window and inside this we place the sub-widgets: small text

labels to provide headings, large text boxes to display DNA sequences and output, buttons

to allow the user to trigger actions and a small text entry box for a user to type into. It is

deliberate  that  we  have  accepted  the  default  styling  for  the  widgets  and  not  tried  to

customise  the  look;  that  comes  later  if  you  can  find  the  time.  The  examples  only

demonstrate a few of the available widget types, but a more complete listing is available in

the on-line documentation for Tkinter and Qt.




Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   427   428   429   430   431   432   433   434   ...   514




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish