1"use strict";(self.webpackChunkdocsv_2=self.webpackChunkdocsv_2||[]).push([[4440],{6180:(n,t,e)=>{e.r(t),e.d(t,{assets:()=>c,contentTitle:()=>d,default:()=>h,frontMatter:()=>a,metadata:()=>o,toc:()=>l});const o=JSON.parse('{"id":"python/qbank/1","title":"GUI","description":"Tkinter GUI Example","source":"@site/docs/four/python/qbank/1.mdx","sourceDirName":"python/qbank","slug":"/python/qbank/1","permalink":"/docs/four/python/qbank/1","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":1,"frontMatter":{"title":"GUI","sidebar_position":1,"description":"Tkinter GUI Example"},"sidebar":"tutorialSidebar","previous":{"title":"Python Question bank","permalink":"/docs/four/category/python-question-bank"},"next":{"title":"Area and Circumference of a Circle","permalink":"/docs/four/python/qbank/2"}}');var i=e(4848),r=e(8453),s=e(8731);const a={title:"GUI",sidebar_position:1,description:"Tkinter GUI Example"},d="Python",c={},l=[];function p(n){const t={admonition:"admonition",blockquote:"blockquote",code:"code",h1:"h1",header:"header",p:"p",pre:"pre",...(0,r.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.header,{children:(0,i.jsx)(t.h1,{id:"python",children:(0,i.jsx)(s.A,{name:"banner",description:"GUI",children:"Python"})})}),"\n",(0,i.jsxs)(t.blockquote,{children:["\n",(0,i.jsx)(t.p,{children:"Write a program that creates a simple GUI with a checkbox, a button, and a listbox."}),"\n"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-python",children:'import tkinter as tk\n\n# Create a tkinter window\nwindow = tk.Tk()\nwindow.title("GUI Example")\n\n# Add a checkbox\ncheckbox = tk.Checkbutton(window, text="Check me!")\ncheckbox.pack()\n\n# Add a button\nbutton = tk.Button(window, text="Click me!")\nbutton.pack()\n\n# Add a listbox\nlistbox = tk.Listbox(window)\nlistbox.insert(1, "Item 1")\nlistbox.insert(2, "Item 2")\nlistbox.insert(3, "Item 3")\nlistbox.pack()\n\n# Start the tkinter main loop\nwindow.mainloop()\n'})}),"\n",(0,i.jsxs)(t.admonition,{type:"note",children:[(0,i.jsx)(t.p,{children:"To compile and run the program, you can use the following commands:"}),(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-bash",children:"python3 foo.py\n"})})]}),"\n",(0,i.jsx)(t.admonition,{type:"note",children:(0,i.jsxs)(t.p,{children:["You require the ",(0,i.jsx)(t.code,{children:"tkinter"})," module to run the program. If you don't have it installed, you can install it using the following command:"]})})]})}function h(n={}){const{wrapper:t}={...(0,r.R)(),...n.components};return t?(0,i.jsx)(t,{...n,children:(0,i.jsx)(p,{...n})}):p(n)}},8731:(n,t,e)=>{e.d(t,{A:()=>r});e(6540);var o=e(6025),i=e(4848);const r=n=>{let{name:t,description:e,children:r}=n;const s=(0,o.Ay)(`/images/${t}.jpg`);return(0,i.jsxs)("div",{style:{display:"inline-block",height:"150px",width:"100%",position:"relative",overflow:"hidden",borderRadius:"5px"},children:[(0,i.jsx)("img",{src:s,alt:s,style:{width:"100%",height:"100%",objectFit:"cover",position:"absolute",zIndex:-1}}),(0,i.jsx)("h2",{style:{color:"white",padding:"12px",boxSizing:"border-box",paddingBottom:"0px",fontWeight:"500"},children:r}),(0,i.jsx)("p",{style:{color:"white",paddingTop:"0px",paddingBottom:"12px",paddingLeft:"12px",paddingRight:"12px",boxSizing:"border-box"},children:e})]})}},8453:(n,t,e)=>{e.d(t,{R:()=>s,x:()=>a});var o=e(6540);const i={},r=o.createContext(i);function s(n){const t=o.useContext(r);return o.useMemo((function(){return"function"==typeof n?n(t):{...t,...n}}),[t,n])}function a(n){let t;return t=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:s(n.components),o.createElement(r.Provider,{value:t},n.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.