Python Tkinter Notebook widget -


using this python recipe, have created notebook widget on tk window. works fine until tried add image each tab. when add image tab, text set no longer shown. wondering if can make text (in case "tab one") show right below image.the following current code:

from tkinter import * class notebook(frame):     def __init__(self, parent, activerelief = solid, inactiverelief = solid, xpad = 4, ypad = 4, activefg = 'black',activebg='green',inactivebg='grey',bd=1,inactivefg = 'black', **kw):                                                                         self.activefg = activefg         self.activebg=activebg         self.bd=bd         self.inactivebg=inactivebg         self.inactivefg = inactivefg         self.deletedtabs = []                 self.xpad = xpad         self.ypad = ypad         self.activerelief = activerelief         self.inactiverelief = inactiverelief                                                        self.kwargs = kw                                                                            self.tabvars = {}                                                                          self.tabs = 0                                                                                                                                                          self.notebookframe = frame(parent)                                                          self.bframe = frame(self.notebookframe)                                                     self.notebook = frame(self.notebookframe, relief = raised, bd = 1, **kw)                    self.notebook.grid_propagate(0)                                                             frame.__init__(self)         self.notebookframe.grid()         self.bframe.grid(row =0, sticky = w)         self.notebook.grid(row = 1, column = 0, columnspan = 27)      def add_tab(self, width = 1, **kw):                         temp = self.tabs                                                                                self.tabvars[self.tabs] = [label(self.bframe, relief = ridge, **kw)]                            self.tabvars[self.tabs][0].bind("<button-1>", lambda event:self.change_tab(temp))               self.tabvars[self.tabs][0].pack(side = left, ipady = self.ypad, ipadx = self.xpad)              self.tabvars[self.tabs].append(frame(self.notebook, **self.kwargs))                             self.tabvars[self.tabs][1].grid(row = 0, column = 0)                                            self.change_tab(0)                                                                              self.tabs += 1                                                                                  return self.tabvars[temp][1]     def change_tab(self, idnum):          in (a in range(0, len(self.tabvars.keys()))):             if not in self.deletedtabs:                                                                   if <> idnum:                                                                                  self.tabvars[i][1].grid_remove()                                                            self.tabvars[i][0]['relief'] = self.inactiverelief                                          self.tabvars[i][0]['fg'] = self.inactivefg                     self.tabvars[i][0]['bg'] = self.inactivebg                     self.tabvars[i][0]['bd'] = self.bd                 else:                                                                                           self.tabvars[i][1].grid()                                                                                         self.tabvars[idnum][0]['relief'] = self.activerelief                                        self.tabvars[i][0]['fg'] = self.activefg                     self.tabvars[i][0]['bg'] = self.activebg                     self.tabvars[i][0]['bd'] = self.bd   root=tk() scheduledimage=photoimage(data="r0lgodlhgacaapcaaaaaaaslcxuvfroagjizgsmjiy0tltirkzu0ndw8peewfkgvfx0aagowfmmygeo3n0jcqkxmtflotlnuvf1sulxcxh9hr2dxv2rkzgplzwxsbhvlzxxjzh1mahtsbhr0dh5ycnx8fkyseqwte6qdhbudhb4agowympyzm58wmkqoklomjqmxmai8plc0ni5otpxotorawqtaqknls7jerbvltbdouatvva5zwbnwvrttvb1xwbjexr9zw7bfyiniy4xoazrtboj0dip1dzj4ekhgykltbbrlzbhkz7vnal1malvra6tycr5xcrr8fmbbxsneycvizmhlzslmamnrbctqbm5ucnbucmv2d8l2d815etjzdnr3edz6fnl8ftt/gysehiymji+qkjotk5eymjycnlkdg7yfhbepj7evlbmdnacfokskpkeoqkurq7ukpk+wsls0tl2xsby8vmepj9acg92dhoggh+ghiooljowpkoqulo6bm/kfn86pqdcrq8oyssk8vpohoctexm3nzd7fxddpz8/q0nxv1dby2nvb2+bozufq0orv1edf3+3c3n7g4opj4+3i4ufp6evr6/lt7e/w8pp19fn19ff4+pz8/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaach5baeaajsalaaaaacaaiaaaaj+adcjheiwomgdcbmqxmiwocohecnkneixoswlgdnq3mixo8epieokhemypmmtkfoqxmmypcuxmgpknemzps2bgcpojkltdm6ozsjnulrgpbhhlckx+bkxtqskces2etopdtoeeyjo3cq1awsnkxzf8uq2rnmtd+beqlqvwlmve2ccixtokkg7dfpqjtrmzloxzajdhwxir2g8dvmotluyubm1lcbnitpicn3clunuepkhk6bpoeohzgthlyvhc9xges26twvrc5xaijqhjufxogdb4iypuo4cn3dg4cg8oa8en34m+juiw43j0i8fic5jenxr1aldxxhdr6vjhh7+bn9+xpjz4hq0durwugmmstqgyi8izuqv+1aubkechndtsime0cudeosrhx567khghnw0kmidfftr4ij7ikhhhnjc4uuqyyvfcbd5xxgffvoukeuuutwbxrnjqidae+/pockk9dlnryhu/gaic0boqacbfi7yyiqqtsihghzimgexqhq4ysecucgiffdnicwj8j3boovtzqkfildqzx9+illbwsfcruiibz7iuecbcso4zb8qrnjkghcqaycwhowywsjrbjeilvvciekkw64h4ypxhumffpdvkd8wsncayf+gcjafgqugyeaeetij4adiimigm1n8cglsgcoh6i3+vzgorzzphmglsxpc8uwkv9ahnxvbicfeimkioumpqfi4z519fjqgqw7igyuhxlklcahibafrlvgiausgl+lqpyyorlgipddamqmiq0acyay4voemnmooweedpeorrr03sbvjbnfoomo2jh7aqw9l3nqse/djp4syy+axggihedsjjilgqeadv7yjojzlfjlhqw7eiymcw641fbgeodawlsxs14n8ccvmegaymkrie2jgsuijborblkshgpdadkb+ddifotqj7x4hynghckeppukiyriqaa2e3odiffd0kgi4c48ljoqxojvfcxbu/fcigkaggrqe10ukie7jiwd+ytba8eg1q4xg1suxnnioli3oqtzlgow7m42q/mreba988eeih2jwwaqbcjf0hqw2yltipfayjx5ltjcabpdbdseegqwa6xrfa9ldi+c+hmg4wfzq4413cchbacqfgaafqpwxl71lny3h09assiqecbr/garcmoeflsracxakt2ui+esz5nwojrhfymwetbtfbbz1ghjh50iy7fzipuub4r161igf+1jigh3smcj7ei9mumdd4lacm/j0ieuqm0k6jswflntbc1/4gh04rb/qjq5vtlvts043waxauatcensuqks7kcghboebn0t2tyuexclgktqcdivobqxq0a7+bzqqkeb1nzurykilk+exetgflqrwhbnryzyst0cvli9rdnvu7/szbsde0icbnjenplxe5+hlvhm4wwdtseqvodgfrykufffua1vjscuzsitoypu+yhwrcz3m4a+dqdqgrahp+evsqdayqs80uyfaglxmdfyr8vuxjriwrcpi9bvzuymlf7zgdzn4sqqdyv4glbcf0jghni7rgk7u4bykz7a6wpj8ldjk4x71k/28ezayxkmy4wsyq+ltkksk4qcz2mqnfncsynoshs+jegxqyhe0sie2dcbnhezgyfrimrzldcmrdbglx1yibu+grgwym5yqlgssdhwmjxysb9z+zieotfmdguaae3dksqauyyccgvsgce2oqhfk0iy6dke3acg1t5lhsvzhohjnqb8yytgoevsjio2oh0zk0pkalksfweqcjmqspgoie5fihexnglozxvsmmk3pjxa6057ufkzaxeloh3ojtbsvqdu1xcuswdsmwqists3qlwdoizfmdkhxfwpqtzpuo2l1q0g9qve9utslwoisz6wewtu6ibykpa1tpuqm4maa8l1ce0tnqk5/+lw+ijwvr82rxpxk1lw6nrkrgerihchyscgcszcdbcbgwnkszbkvoyxrx4mqwar2drogxwpkjofysjhweahnhgpxy9peopypbqj+k1uxc9rphva2fyxswschcdjcnrwjqirwcxmxwragey9tg2xbctmhkjwp0h3ucwn7iuo4f7qhfspbdwsjrqqxm4ygxcdgo945jdcq5b0eiqsjidus92zvfa5tnzvf2xy2mmpne2o9i4jikncoai5dboja4alhbscvicn7gvhvs+q2rex1simjw10kmzwplkieyegk2nt2d73lhtacruygnrrhdwwowxpuzay2tke0ysia7iqhcqtjqrqymop0b0zu6zz1qrrwcfphi1hh8bfegxhwhobg4hstyqxiceouxudlkothdgx4gixnsikao3xcto1qml+s3bxidxkukmt+bxxx4ueeysbucamb1kcgkpeeympacotxtocri+edfaissdkzcabyomkitssndwvhp1yxzwagdgtubotgijfjs5zziu0sztgqiq6dsiqkbjpuz1hceyaywxqgldivvcc+y461rjtq5lotucpbpur5m33imowbdd0pwyacczvp2pqs4r2rachxcdimiqwzqkzcz83omep1vry+82gpvgsm9xnyunadikbdu6s2gqxilslokdgzp5ukatootvqpvdsz9zauhe6sd8pr5iw3icxpbgov49blq3a1x5agc2hvkwnhhaedjmeajekda6iiga6rhi1vi2hknsdgznqoa7d+xdcggmdvrzudrbnq7vfpgnsqygade0ic70zmw7tnztlada7xe7f13qnvm8fzhn4ay9nxig/dgawbmvosdrjpxm1rb6mumwwgjboyhm2duvmxzxjjcmv32pwrwn7xxg0rjjmw11bwqtsxencahi9vc5o5hceewjdrrtwmvlvdvri+jy1v/17kfy/x32kha7dj4bmu97xhcjf740p7gute/cnz37qzh5zwshs+8icdeilmdge01xncg/gmab2fvei0qfjul7umikggmhgk82vf9pa/7/nb53u/ibbvbhqt9jaqqvwxv+klllagrmzd7z+hbbna0jeisfbs2f45yt3+qmbbr6k33y/86pt99oifn7axz+nfyhci57vdm5s4/eayjgm/57f3nn9r6pebcf0pig5h92vafgjil3w9lgibmqkgsfsfeql3txhwt3zz9lagj3h/z4glzwljbgcad3dh4ayvtybidtvjmagkifus5xlye20zmqgrshxg532qnynch1jdr1qmhth9hwknvnvargariyjizqmjiazxaalcmfmfmqhhsbsy4yiwkakajxt39n0cdofvjx6guf4bqhhhaakhmirjvysvj4y79rlrqh0yyx1smxyz+izw+iam5qjftyftshkkbwzzeizm+cqkb3tj6bmqeayasiykeg/+nzgmmqii2yeh+0yigqcafrycyfagnmggznuinuz8mpgzdregl5ifctikcchydvgbd/hslhgi6geglnaiasejnwgjyfabfxeb/0kkutiirvzp/lzkiuejzhcjmjhuhxacidb+xshtg6cgfyglszgdvvwg0zik/lefw7dqdwcgriijv/wkmhmij+inlyaghfimuvhkcqiokkvyjgbz71hpwzdkcnz6ydagxch1rpd0x/gbjiickoczcecme4gllkbyu6ilc8hfh2d62xghffimr5g5/xiixtv7yhb1bfkfi5vyiguj78hxicvxcbmp+naktozryecj47apishsh4d+axewjsr3v59fyucfcwsadxqbje24jiyjh/fozgwmfbxybmjaiwjwbmvojcgaaxhndti2vnyhvji1bwqzeqnqbih2zm6wzoifxm4wcoifyab2lnfgf/tibrvhibargkjicykqk2sgevlfvpmwznmwe5mgcgdghbkbabpgcdkgwtj1xzylyenfcmphbqrijrgjgli3krhabobivjhxhrehx36hzjdgibqbaroqaojwulzlvqx3mjnlmjm1mnmoiiewca1yjhizk0izd9q2l3tzvgxakxiradmxaoqqcavru8qpu5hgnd51y+bfmhfwhzfhituphlkfkxhqmdovzml+h38/n2lxfvnx4jsrmqfuaaficalghzzqovpjmwpt6vzmzydiiyz4ojuycjmv8agiufhxxva6wwvypx7icretmaeg4aaugaljpxxg1abhvzhmfz+1swmyswzm2zsxyj0a4b+ep3h4pneg6qgycai2obetsbyd0aauoi6vyf1i5ajipvysyog1jwqawayxaocsn5evijoh8fqk+ho9z4wk5xo9hqlwm3pj6reimahs8afhqjm71aj/zv3xxm7ldzrjqqftejmtz4dmpgevuaehqazuagqvgqiujzjeqn8vkfmkoafksqamygzocqwucghvnavj5ajnxryswn4hoah+b7maeqvxleaiyjqmjiobhyaeybagpafehqcmj7v9f3hxmbajghabjuoxqnwka/abykcluwvdylzdglyvxeihgsb2kjaxhkcalolbcqkgftaburqrupqrvzobhwagzfaahoba79hwlzzetyknnzp0djqqy/bu0pphf5pz9yuzwqqdgzogirahy0ag4joix+p2cikhjmabrmm6lqmb6zo57mo5liosxplyk8cwk7cgidahzcorbepy8hgiwuygomd1tnwiu8wqpdifglagz2vapuv+sxc1gbackyah6nvp65wxgrtehsfcxvpwqivcipcogibob9gvqjwyw0ggh8d+bjuxywpvlz0ncwikikgjbhoqbtmphl3hwipgaiugb8g1kjmykj+5weylh545bxdxrcmbwocwb2nwo9mml6ofpv/nbirjonefiaslcinaa0glcahzjbpyhzj6hpsacwxwjvw6b0+bsv0xcczrbj2hzr1lwjeab+rveigxovq3cfl3typaa0g7iwmzuhc4tmlagvzqfkrlxa61b3ngjnybgx4acw6gxhvilrwiad0yl/pmceswam+ajoqbupdfvcggkutklhhrxyzzuathnec3ucjxymvwdxgagn9vq9howifgbkb7o0a5gwj5hgh5qxe4gxgamomzb3toxy2wwpl+o7symacbv6rpgli4i2lonwadcgyfufmd9vuhgabfy7yqq7gkyltpoadeoblpa2l2hwhl4x3v+l0avmltx66quktp95gkcahqiajqylzwsipj+4ax2sbpgqnqvheteaesu1pqkrj2cgcptxyjyjvmv34xczecfjcmlvii8aykkay/eqmp9ckoofikemmx/finzwso1wevnmp/gqfx0znw2wiss70xhfz/b20eliebo49ziafhcwyyaay7q1cxc8jsjgcqwmlma5igwvoqljjfxfo5balx4lgmashwm8bedwrwaayfqagxzhhxyjwhcgmpcyeeiagislnj5zeocwn+ibailmdcxijaolzdmwzdiyzim0yujvxcd0sjt2krfcxfatparrvebjaeh2aijwysjsagg9ayplggyiaegbct2hvwppxbtdocznaixjk0qnph6jihoui0ruvcj2ujg4abjpsqeqah1ivjgfy9o0ci5qmf3uxdxjnm2bq7goabzjedimdf9wsim2aghkc/t/vikqvohtziswvih/wuljcrtwghwsvchhuygqzpumaepila3cwvikcwgxi+tykgagxj75jijjv6rcdnk2vlo8zdqbrqc8jdmpzd4wwjtbvmwhwhxuzoymxa+zyimincqcxk/xuxswazetwisqg79pz+wozgbewgyzmszuucuyg9zjp9wkkbabghaezszu/m0z4txlrgbsjowonaboqq0myhggwjbsakcafxwerzaydgbkxqqessw4x3yckpyi31wl5tzpgizmtqtoscxkrvcp1l1u5s1hi8hui9lo01cmpfb6x8z6kcgskl1sglblvtqbhbxd9czjxtyop8wjqwcbngqrgbaewmz5ccz48d2ek1bpry1ke218i3flslahggznndf29q1d4ct4kgxdettzwdwsalfhdjuhbb2d8d27i9j6mabsjwdowr1ckjbfibfhilcezg1ae9ymnnh/t12ihzuhsbacj2ls7t3gt53m7+/zwpf8urt3lgwmc6szkzm6yzmkurqnsaimujynyru8yxvmzejd6tq8aq7vqkpc7ldqejaah0xd/2td/5/qd5nd/4fd8ggaafmaacmaaexuackoakruatoahionbqxnoypdr1g7eppcnq9nau/raa0oee/ueghuiipuikhgan7h/hxefpvol0y1pchlkw3t7eglhhuafzehunaqac0knoaegqlbmnugnl/ennxd4wpsrexd7uamjqi+mewgfkomoyjotgnorwpuwinqczeghoxheqqky7qoerjeasheqcen5oxsxkths52uuxyqbjygyvbnyzfdax3ahs2vp1hrm2ibuiyqrybn4rx06ojvaidjjbj63wed7opb25ikuigfndgz4rbacrc4smwkxwhtsg3bqyzv3sihceuxrjk44rbrabe1abejjkma6md2i95dwizzaburrhpa6vvfobzwcgq45yzwnyutygukyrebbgt/4rbzaaqi7qfbabyahsqudgphwbejabegdsx04saxdg9s0vbpeaap7t4j7u5f7u5n7u6j7u6r7u7n7u7v7u8b7v8j4taqeaow==") note=notebook(root, width= 400, height =400, activefg = 'red', inactivefg = 'blue') note.grid() tab1 = note.add_tab(text = "tab one",image=scheduledimage) tab2 = note.add_tab(text = "tab two")                                                 tab3 = note.add_tab(text = "tab three") root.mainloop() 

label reference: compound

controls how combine text , image in label. default, if image or bitmap given, drawn instead of text. if option set center, text drawn on top of image. if option set 1 of bottom, left, right, or top, image drawn besides text (use bottom draw image under text, etc.). default none.

tab1 = note.add_tab(text = "tab one",image=scheduledimage, compound=top) 

ttk.notebook sample:

from tkinter import * ttk import *  root = tk() scheduledimage=photoimage(...) note = notebook(root)  tab1 = frame(note) tab2 = frame(note) tab3 = frame(note) button(tab1, text='exit', command=root.destroy).pack(padx=100, pady=100)  note.add(tab1, text = "tab one",image=scheduledimage, compound=top) note.add(tab2, text = "tab two") note.add(tab3, text = "tab three") note.pack() root.mainloop() exit() 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -