from Tkinter import *
def mostrar(num):
v1 = Toplevel(v0)
v1.title('Ventana hija')
v1.protocol('WM_DELETE_WINDOW', 'onexit')
v1.config(bg='blue')
v1.geometry('800x500')
if num == 1:
hola = Canvas(v1, width=800, height=800, bg='white')
hola.pack(expand=YES, fill=BOTH)
hola.create_polygon(300, 300, 400, 200, 500, 200, 600, 300, 700, 200, 800, 200, 900, 300, 878, 395, 600, 700,
325, 401, fill="red", outline="brown", width=6)
b1 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b1.grid(row=1, column=3)
elif num == 2:
hola = Canvas(v1, width=500, height=500, bg='white')
hola.pack(expand=YES, fill=BOTH)
hola.create_polygon(400, 50, 350, 150, 400, 250, 450, 150, fill="red", outline="red", width=6)
hola.create_polygon(400, 250, 300, 250, 250, 350, 350, 350, fill="red", outline="red", width=6)
hola.create_polygon(400, 250, 450, 350, 550, 350, 500, 250, fill="red", outline="red", width=6)
b2 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b2.grid(row=1, column=3)
elif num == 3:
hola = Canvas(v1, width=300, height=210, bg="black")
hola.pack(expand=YES, fill=BOTH)
hola.create_polygon(130, 420, 130, 100, 200, 100, 200, 420,
400, 420, 400, 100, 470, 100, 470, 420,
130, 420, 400, 100, 200, 100, 470, 420,
400, 420, 130, 100, 470, 100, 200, 420,
fill="white")
b3 = Button(hola, text='ocultar', command=lambda: ejecutar(Ocultar(v1)))
b3.grid(row=1, column=3)
elif num == 4:
hola = Canvas(v1, width=500, height=500, bg="skyblue")
hola.pack(expand=YES, fill=BOTH)
# flor
hola.create_polygon(140, 100, 180, 130, 220, 100, 260, 130, 300, 100, 300, 180, 260, 220,
180, 220, 140, 180,
width=2, fill="red", outline="darkred")
# tallo
hola.create_rectangle(215, 220, 225, 410, width=2, fill="forestgreen", outline="darkgreen")
# hojas
hola.create_polygon(80, 250, 170, 260, 215, 320, 140, 310, width=2, fill="forestgreen", outline="darkgreen")
hola.create_polygon(225, 320, 275, 260, 365, 250, 305, 310, width=2, fill="forestgreen", outline="darkgreen")
# maceta
hola.create_polygon(120, 390, 320, 390, 280, 490, 160, 490, width=2, fill="sienna", outline="black")
b4 = Button(hola, text='ocultar', command=lambda: ejecutar(Ocultar(v1)))
b4.grid(row=1, column=3)
elif num == 5:
hola = Canvas(v1, width=550, height=600, bg="BLACK")
hola.pack(expand=YES, fill=BOTH)
# cuerpo pacman
hola.create_arc(80, 200, 180, 300, extent=290, style=PIESLICE, start=40, width=2, fill="YELLOW",
outline="gold")
# ojos
hola.create_arc(120, 215, 145, 240, extent=320, style=PIESLICE, start=220, width=2, fill="black",
outline="white")
# camino
hola.create_rectangle(5, 10, 300, 40, width=5, fill='black', outline="red")
hola.create_rectangle(5, 160, 400, 190, width=5, fill='black', outline="red")
hola.create_rectangle(440, 5, 480, 35, width=5, fill='black', outline="red")
hola.create_rectangle(30, 340, 60, 600, width=5, fill='black', outline="red")
hola.create_rectangle(200, 360, 260, 390, width=5, fill='black', outline="red")
hola.create_rectangle(515, 210, 545, 300, width=5, fill='black', outline="red")
hola.create_polygon(210, 500, 210, 530, 400, 530, 400, 310, 370, 310, 370, 500, width=5, fill="black",
outline="red")
# enemigo fantasma
hola.create_polygon(460, 530, 480, 510, 520, 510, 540, 530, 540, 590, 530, 570, 515, 590,
500, 570, 485, 590, 470, 570, 460, 590, 460, 530, width=3, fill='salmon', outline="pink")
# ojos
hola.create_oval(475, 530, 495, 550, width=2, fill="white", outline="salmon")
hola.create_oval(505, 530, 525, 550, width=2, fill="white", outline="salmon")
# pupila
hola.create_oval(477, 534, 487, 546, width=1, fill="midnightblue", outline="navy")
hola.create_oval(507, 534, 517, 546, width=1, fill="midnightblue", outline="navy")
b5 = Button(hola, text='ocultar', command=lambda: ejecutar(Ocultar(v1)))
b5.grid(row=1, column=3)
elif num == 6:
hola = Canvas(v1, width=700, height=550, bg="black")
hola.pack(expand=YES, fill=BOTH)
# cuerpo coordenadas
hola.create_polygon(100, 100, 420, 100, 500, 180, 500, 220, 460, 260, 460, 400, 500, 430,
500, 460, 460, 460, 420, 420, 420, 340, 380, 300, 340, 340, 340, 460,
260, 460, 260, 340, 260, 460, 180, 460, 180, 340, 180, 460, 140, 460,
140, 340, 140, 460, 80, 460, 40, 340, 40, 200, 20, 280, 13, 280, 35, 195,
width=4, fill="gray", outline="black")
# cuernos forma triangular
hola.create_polygon(350, 275, 445, 298, 350, 298, width=2, fill="white", outline="dimgray")
hola.create_polygon(460, 275, 550, 298, 460, 298, width=2, fill="white", outline="dimgray")
# orejas octagono
hola.create_polygon(260, 100, 300, 100, 340, 140, 340, 220, 300, 260, 260, 260,
220, 220, 220, 140, width=2, fill="gray", outline="dimgray")
hola.create_polygon(460, 140, 500, 100, 540, 100, 580, 140, 580, 220, 540, 260,
500, 260, 470, 250, 500, 220, 500, 180, width=2, fill="gray", outline="dimgray")
# ojos ovalo
hola.create_oval(390, 230, 410, 260, width=1, fill="black", outline="black")
b6 = Button(hola, text='ocultar', command=lambda: ejecutar(Ocultar(v1)))
b6.grid(row=1, column=3)
elif num == 7:
hola = Canvas(v1, width=800, height=800, bg='white')
hola = Canvas(v1, width=210, height=210, bg='pink')
hola.pack(expand=YES, fill=BOTH)
hola.create_polygon(382.6, 54.5,
339.07, 56.3,
311.48, 99.02,
284.55, 99.02,
284.78, 141.74,
334.62, 141.74,
336.4, 180.91,
313.26, 212.95,
339.96, 240.54,
338.18, 212.06,
375.56, 254.78,
355, 286,
384.46, 302.84,
454.78, 303.73,
456.56, 210.28,
347.97, 113.26,
340.85, 97.24, fill="white", outline="black", width=6)
b7 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b7.grid(row=1, column=3)
elif num == 8:
hola = Canvas(v1, width=800, height=800, bg='white')
hola.pack(expand=YES, fill=BOTH)
hola.create_polygon(250, 50, 200, 50, 200, 100, 250, 100, 250, 150, 200, 150, 200, 200, 150, 200, 150, 250, 100,
250, 100, 400, 150, 400, 150, 300, 200, 300, 200, 450, 350, 450, 350, 400, 250, 400, 250, 350,
500, 350, 500, 400, 400, 400, 400, 450, 550, 450, 550, 300, 600, 300, 600, 400,
650, 400, 650, 250, 600, 250, 600, 200, 550, 200, 550, 150, 500, 150, 500, 100, 550, 100, 550,
50, 450, 50, 450, 150, 300, 150, 300, 50, fill="black", outline="lightblue", width=6)
hola.create_polygon(250, 200, 250, 250, 300, 250, 300, 200, fill="white", outline="white", width=6)
hola.create_polygon(500, 200, 450, 200, 450, 250, 500, 250, fill="white", outline="white", width=6)
b8 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b8.grid(row=1, column=3)
elif num == 9:
hola = Canvas(v1, width=300, height=210, bg="white")
hola.pack(expand=YES, fill=BOTH)
hola.create_polygon(100, 150, 300, 450, 500, 150, 380, 150, 380, 120, 360, 120,
360, 150, 310, 150, 310, 90, 290, 90, 290, 150, 240, 150, 240, 120,
220, 120, 220, 150, fill="black")
hola.create_polygon(160, 180, 300, 400, 440, 180, 380, 180, 380, 210,
360, 210, 360, 180, 310, 180, 310, 240, 290, 240,
290, 180, 240, 180, 240, 210, 220, 210, 220, 180, fill="white")
b9 = Button(hola, text='ocultar', command=lambda: ejecutar(Ocultar(v1)))
b9.grid(row=1, column=3)
elif num == 10:
hola = Canvas(v1, width=400, height=400, bg="green")
hola.pack(expand=YES, fill=BOTH)
hola.create_polygon(40, 180, 200, 180, 200, 60, 40, 60, width=4, fill="gray", outline="black")
hola.create_polygon(60, 120, 100, 120, 100, 80, 60, 80, width=4, fill="gray", outline="black")
hola.create_polygon(140, 120, 180, 120, 180, 80, 140, 80, width=4, fill="gray", outline="black")
hola.create_polygon(80, 160, 160, 160, 160, 140, 80, 140, width=4, fill="gray", outline="black")
hola.create_polygon(100, 60, 60, 20, width=2, fill="gray", outline="black")
hola.create_polygon(140, 60, 180, 20, width=2, fill="gray", outline="black")
hola.create_polygon(100, 160, 100, 140, width=2, fill="gray", outline="black")
hola.create_polygon(120, 160, 120, 140, width=2, fill="gray", outline="black")
hola.create_polygon(140, 160, 140, 140, width=2, fill="gray", outline="black")
b10 = Button(hola, text='ocultar', command=lambda: ejecutar(Ocultar(v1)))
b10.grid(row=1, column=3)
elif num == 11:
hola = Canvas(v1, width=500, height=500, bg="gray")
hola.pack(expand=YES, fill=BOTH)
hola.create_polygon(202.9761194370994, 459.4555645208418, 302.8134805335928, 460.0196174083926,
312.9664325095075, 421.0999681673856, 334.4004422364383, 414.3313335167757,
367.6795626019361, 442.533977894317, 420.7005340317123, 401.3581171031067,
403.778947405188, 366.3868380749554, 419.0083753690599, 344.3887754604732,
458.4920774976167, 350.0293043359815, 479.9260872245475, 289.1115924804923,
444.9548081963972, 268.2416356411117, 444.4064859562329, 241.8565804562907,
480, 220, 461.2142727412988, 161.3322065712142, 418.3187804621004, 163.5605438324713,
404.948756894558, 142.9484241658429, 422.2183706693002, 108.4091966163574,
370.8458258323626, 68.9289263102584, 338.7634424485586, 97.1272000498291,
316.2701030936517, 89.1210962116416, 307.6853964093092, 47.1347225980438,
199.8879836016924, 47.7688250263239, 199.5709323875523, 115.3007336381564,
214.1552882379946, 107.3744532846549, 227.1543880177367, 104.2039411432543,
238.8852829409185, 103.8868899291143, 249.0309217934001, 106.1062484280947,
260, 100, 271.2245067832035, 97.8629168604532, 283.9065553488056, 98.1799680745932,
295.6374502719874, 101.6675314301339, 304.8319354820488, 105.4721459998146,
320.0503937607712, 113.7154775674561, 328.9278277566926, 121.9588091350976,
335.9029544677737, 133.6897040582798, 338.7564153950341, 142.8841892683415,
339.3905178233142, 148.9081623370026, 347.3167981768155, 148.2740599087225,
355.2430785303167, 151.127520835983, 362.3205776400985, 156.3788148945879,
367.7022882868521, 163.9132098000432, 370.0087357068894, 172.0626573508416,
371.3926041589117, 180.0583417403043, 371.3614620486748, 189.0452306761152,
370.475216735828, 197.1986875543063, 367.4619826721488, 202.338910368818,
376.9014215697061, 208.4847087767439, 389.8245024020653, 210.5803435063157,
401.3504934147099, 209.8817985964584, 409.7330323329969, 205.6905291373148,
413.9243017921403, 216.1687027851738, 417.4170263414266, 235.0294153513201,
418.8141161611411, 255.2872177371808, 416.53312864442, 275.0083869090581,
412.1475561751611, 295.8398561380383, 404.7541868469949, 313.531079988644,
394.9233746041279, 332.0394094660915, 378.3126217551115, 353.4726389486938,
364.0516579708352, 367.9368482289425, 334.8413789422513, 387.0358768245555,
316.8658226169688, 393.0277289329831, 300.3882293187933, 397.1471272575271,
280, 400, 260, 400, 241.5931805048488, 395.6491642304202,
243.0911435319556, 390.0318028787693, 249.4574863971598, 390.0318028787693,
263.3136443978983, 389.2828213652159, 279.4167469392972, 385.5379137974486,
291.0259603993754, 381.4185154729046, 300.76272007557, 376.9246263915839,
309.7504982382113, 373.5542095805934, 319.4872579144059, 366.8133759586123,
331.8454528880375, 360.0725423366313, 340.0842495371253, 352.2082364443201,
344.9526293752226, 342.8459675249019, 347.5740646726597, 329.3643002809397,
335.215869699028, 336.8541154164743, 320.2362394279593, 343.5949490384554,
301.5117015891234, 349.9612919036597, 271.5524410469861, 358.5745793095244,
257.3217922894709, 361.1960146069615, 241.9676712616255, 363.4429591476218,
220.6216981253526, 364.9409221747287,212.0084107194881, 365.3154129315054,
212.0084107194881, 356.327634768864,223.6176241795663, 356.7021255256407,
240.4697082345186, 354.8296717417571,260.3177183436846, 352.2082364443201,
281.2892007231807, 345.8418935791157,277.1698023986369, 341.348004497795,
276.0463301283067, 335.7306431461441,265.9350796953353, 339.1010599571346,
253.202393964927, 343.2204582816786,241.218689748072, 346.5908750926691,
226.6135502337801, 348.8378196333295,212.7573922330415, 348.4633288765528,
212.3829014762648, 343.2204582816786,220, 340,238.2227636938583, 336.1051339029208,
251.7044309378201, 333.109207848707,263.3136443978983, 332.3602263351536,
264.0626259114518, 321.4999943886285,252.4534124513735, 323.7469389292889,
238.2227636938583, 328.2408280106096,220.9961888821293, 331.9857355783768,
212.3829014762648, 334.2326801190372,212.0084107194881, 325.6193927131725,
220.9961888821293, 322.9979574157354,239.7207267209652, 317.3805960640846,
265.9350796953353, 311.3887439556569)
hola.create_polygon(270.0544780198792, 304.2734195768991,277.1698023986369, 297.5325859549181,
268.5565149927723, 297.5325859549181,257.3217922894709, 299.4050397388017,
239.1071354949687, 304.9944241491205,221.3410876172071, 310.9829796135347,
211.7593988741446, 314.5761128921831,211.3601618431836, 304.5951871181596,
261.4644092287812, 290.6218910345265,
255.6754722798476, 284.8329540855929,
239.9056095568906, 285.2321911165538,
212.1586359051055, 286.0306651784757,
211.7593988741446, 277.247450497335,
270.2476239099217, 276.848213466374,
267.6525832086757, 272.4566061258037,
266.6544906312733, 267.6657617542723,
267.6525832086757, 263.2741544137019,
269.8483868789608, 258.6829285576511,
261.4644092287812, 259.481402619573,
248.2895872070703, 260.2798766814949,
238.3086614330469, 261.2779692588973,
228.128117143543, 262.2760618362996,
220.7422320707657, 262.2760618362996,
211.5597803586641, 263.2741544137019,
211.5597803586641, 254.6905582480417,
244.0975983819804, 255.2894137944831,
200.9799990381993, 232.1336659987484,
fill="blue", outline="black", width=2)
hola.create_polygon(252.7838633634599, 250.7204848622283,
246.8157615627554, 249.7258012287775,
237.614937953336, 245.249724878249,
226.6734179853777, 239.0329521691817,
214.488543475606, 231.0754831015756,
199.8169598822074, 217.3985831416275,
195.340883531679, 209.1924431656586,
195.5895544400417, 200.4889613729644,
196.5842380734925, 190.293454130094,
200, 180,
200.8116435156581, 174.6271869032444,
206.2824034996373, 184.3253523293894,
214.9858852923313, 198.4995941060629,
221.2026580013986, 209.689784982384,
234.6308870529837, 230.5781412848502,
243.0856979373151, 239.7789648942698,
249.3024706463823, 245.9957376033371,
fill="blue", outline="black", width=2)
hola.create_polygon(263.865734571309, 252.304090318045,
256.1179110406345, 240.3595290415882,
242.5592198619541, 222.2812741366807,
223.1896610352678, 194.1954138379851,
207.0483620130293, 167.7236834415134,
198.3320605410205, 148.3541246148268,
196.0722786779071, 139.6378231428178,
197.0407566192414, 133.1813035339222,
203.4972762281368, 127.693261866361,
213.9759600976109, 122.1012882139243,
226.2524631835424, 119.6459875967379,
242.7575395546281, 119.5095820068942,
245.4177123269611, 153.3900411275854,
250.4626816485015, 190.9120004565429,
254.2464086396568, 211.7224989078975,
258.3454462134084, 226.2267857073265,
262.5241371143508, 239.6905375342968,
268.3598648365041, 251.2485771138015,
fill="blue", outline="black", width=2)
hola.create_polygon(275.0713774000567, 247.5676293576013,
266.9932794997881, 222.4976703567673,
262.53639789964, 195.199270555859,
261.1436223995937, 175.9789686552196,
260.8650672995844, 149.7947892543485,
261.4221774996029, 114.9754017531901,
282.0352549002882, 114.1397364531622,
305.7124384010753, 119.1537282533291,
317.9688628014827, 127.5103812536071,
325.2112954017235, 137.5383648539407,
329.1110668018532, 146.4521280542372,
319.0830832015198, 151.1875647543948,
309.8907649012142, 158.4299973546358,
300.1413364008901, 169.2936462549972,
294.2916793006956, 179.0430747553216,
290.391907900566, 189.3496134556644,
285.9350263004178, 206.0629194562205,
283.7065855003437, 221.3834499567302,
283.7065855003437, 243.110747757453,
fill="blue", outline="black", width=2)
hola.create_polygon(291.5884636600201, 239.2427776530637,
291.8069435482862, 225.9155044688321,
294.4287022074793, 209.3110329606092,
299.0167798610671, 194.0174407819829,
299.0167798610671, 194.0174407819829,
317.8060502519504, 168.4552938548502,
332.6626826540443, 160.1530581007388,
345.5529960617433, 157.5312994415457,
354.6111686008223, 165.4963226277015,
359.5427205978758, 175.1950415552404,
361.6797264632657, 183.5786799502315,
360.0358757975812, 197.7157956751186,
354.118013401117, 196.400715142571,
349.8440016703373, 195.5787898097287,
336.6931963448612, 195.0856346100233,
327.158862483891, 197.0582554088448,
320, 200,
309.8984304942038, 208.2364399354997,
303.9805680977395, 214.6474575316694,
299.2134011672544, 222.2091705938183,
294.1854388309027, 233.078963816809,
fill="blue", outline="black", width=2)
hola.create_polygon(296.9390377919526, 238.4222151255614,
300.210417992851, 231.7803219904039,
310, 220,
320.5199539711998, 211.0963109028553,
330.2983336575473, 205.8682663180754,
335, 205,
345, 205,
353.1019113154815, 208.7288095766401,
356.3179308098636, 211.0872238725204,
352.2443061169796, 211.0872238725204,
346.5626716769045, 211.0872238725204,
342.703448283646, 212.1592303706478,
339.1658268398256, 214.946447265779,
335.735406045818, 219.3416739081014,
335.1994027967543, 224.1657031496747,
338.5226229409492, 225.7737128968658,
341.6314417855186, 226.6313180953677,
340.7738365870167, 232.3129525354429,
345.3834645289644, 234.2425642320723,
342.5817031876476, 234.234323635067,
344.5348128081197, 236.9392924680085,
344.1988441609097, 240.886924072727,
347.2225619858004, 243.9106418976178,
352.0101152085439, 244.2466105448278,
356.1257311368673, 246.6823832371009,
357.3016214021026, 251.6379207834496,
357.2670624208558, 255.3026595268844,
349.8136249880008, 274.3476995407687,
349.0806501564367, 279.9478187410201,
350.545741801065, 281.5145646089745,
352.6207587856511, 281.3463199886027,
353.3498188072624, 280.2246891861237,
356.3221404338317, 280.1125261058758,
362.8932246239414, 287.162040829641,
363.3196560929043, 290.7156364043316,
361.908716324427, 292.9899251919686,
357.1594061045018, 296.0873014223546,
351.997112387192, 297.6704048289963,
351.7217900556021, 290.1678712931725,
350.6893313121401, 287.001664479889,
348.4179220765238, 285.2808999074524,
340.9842191235975, 284.8679164100676,
336.5102312352623, 283.9042882495031,
331.0726151863625, 280.8069120191171,
332.9310409245941, 278.7419945321931,
342.4296613644443, 278.8108251150906,
344.2192565197784, 277.5718746229362,
344.3569176855733, 274.887481889935,
341.6851396438104, 270.6351879979023,
338.8655066966085, 268.4922669580289,
332.8878848485405, 267.8155550507004,
328.3764721330174, 272.1013971304474,
329.6188832460051, 274.1537251585691,
331.8596093975631, 276.562505771494,
326.5939029414017, 276.7305602328609,
323.0956851898579, 275.0739270951335,
318.9556277994099, 270.9780232943002,
316.2614187361876, 266.8515605387831,
314.0751216507222, 262.2204071144092,
312.226663241625, 255.1345619987713,
312.27627775426, 245.8399686803374,
312.3496735873269, 241.876593694725,
319.7626527270835, 231.8213645645602,
320.5700068908194, 228.5919479096167,
318.8085068972139, 225.7295104200078,
315.6524860753373, 223.7478229272016,
311.0285485921228, 224.5551770909375,
306.7715902742428, 227.3442187474795,
298.037486139282, 237.0324687123098,
fill="blue", outline="black", width=2)
hola.create_polygon(300.0617375788183, 244.2929670499564,
306.3278631364796, 250.0369154778124,
306.3858828175691, 242.2622782118254,
307.7203354826266, 237.8527824490268,
311.3755753912624, 231.876755296813,
309.3448865531313, 232.4569521077075,
305.2835088768694, 236.9244675515956,
301.802328011502, 241.3919829954836,
300.5258950275339, 243.4226718336146,
fill="blue", outline="black", width=2)
hola.create_polygon(350.2661249469691, 346.7894284219767,
355.0583499545213, 337.033827513746,
357.6256133514242, 325.7378685673735,
357.4544624582973, 317.6937765904113,
357.2833115651705, 311.1900426515908,
355.0583499545213, 305.028610499024,
366.1831580077673, 300.7498381708526,
378.3348714197745, 294.5884060182858,
385.5232089311027, 288.7692756519727,
389.973132152401, 283.2924470719134,
391.1711884042891, 276.617562239966,
391.6846410836696, 272.6810916980484,
387.9193214348787, 265.6639050798473,
396.4768660912218, 270.6272809805261,
400, 280,
401.097940205647, 291.8499917282562,
396.8191678774755, 306.9112703234194,
392.1980937630502, 318.036078376665,
385.3520580379758, 327.2782266055152,
377.8214187403939, 334.1242623305894,
368.5792705115434, 339.9433926969025,
355.0583499545213, 345.9336739563424,
fill="blue", outline="black", width=2)
hola.create_polygon(319.4283345656475, 332.1120026243448,
319.4283345656475, 324.8933647631799,
317.2072152237506, 318.4151000159805,
314.2457227678879, 313.7877680536952,
307.3972714637055, 309.9008092053757,
317.5774017807333, 309.5306226483928,
329.9786514396582, 311.3815554333069,
338.8631288072461, 314.1579546106781,
346.6370465038856, 318.7852865729633,
322.0196404645274, 331.0014429533963,
fill="blue", outline="black", width=2)
hola.create_polygon(344.4642814864766, 296.5520153997359,
344.5965257974588, 301.8417878390208,
347.7703892610298, 309.1152249430376,
340.8936850899591, 305.4123842355381,
332.1655605651387, 303.0319866378599,
311.4032037409447, 303.2964752598241,
298.9401678526973, 303.2616271794951,
290.628911835822, 305.4487998155149,
282.9009018552185, 309.8231450875544,
278.2349335650429, 315.2181709230698,
274.2980228202072, 323.0919924127409,
274.2980228202072, 317.4053435590895,
276.922629983431, 310.6980141419623,
280.1304831829268, 305.4487998155149,
287.8584931635302, 297.7207898349117,
295.8781261622696, 300.6370200162714,
305.5016857607568, 301.2202660525433,
315.2710568683121, 301.2202660525433,
325.7694855212073, 301.0744545434753,
334.8097990834226, 299.0330934165236,
341.954563027754, 297.2833553077078,
fill="blue", outline="black", width=2)
hola.create_polygon(279.7097805171387, 287.6379579767697,
290.2790474814249, 293.6599821773514,
307.3619324585854, 295.9950527857401,
322.3555437335032, 294.520271348863,
338.8239364452982, 291.3249115689625,
332.4332168854971, 290.0959270382316,
321.4952545619915, 285.6715827276002,
316.0877226267752, 281.7388322292612,
312.0320736753631, 275.3481126694602,
308.7138154423894, 281.3701368700419,
301.831502070296, 287.6379579767697,
292.85991499596, 289.7272316790123,
284.5028201869894, 288.8669425075007,
fill="blue", outline="black", width=2)
b11 = Button(hola, text='ocultar', command=lambda: ejecutar(Ocultar(v1)))
b11.grid(row=12, column=6)
def Ocultar(ventana):
ventana.destroy()
def ejecutar(f):
v0.after(200, f)
v0 = Tk() # Este es mi objeto ventana
v0.title('Ventana Madre')
v0.config(bg='black')
v0.geometry('500x500')
b1 = Button(v0, text='Figura Daniel Luna', command=lambda: ejecutar(mostrar(1)))
b1.grid(row=1, column=10)
b2 = Button(v0, text='Figura Luis Rincon', command=lambda: ejecutar(mostrar(2)))
b2.grid(row=4, column=10)
b3 = Button(v0, text='Figura Nadia Rodriguez', command=lambda: ejecutar(mostrar(3)))
b3.grid(row=6, column=10)
b4 = Button(v0, text='Figura Wendy Lopez', command=lambda: ejecutar(mostrar(4)))
b4.grid(row=8, column=10)
b5 = Button(v0, text='Figura Wendy Lopez2', command=lambda: ejecutar(mostrar(5)))
b5.grid(row=10, column=10)
b6 = Button(v0, text='Figura Wendy Lopez3', command=lambda: ejecutar(mostrar(6)))
b6.grid(row=12, column=10)
b7 = Button(v0, text='Figura Gustavo Vazquez', command=lambda: ejecutar(mostrar(7)))
b7.grid(row=14, column=10)
b8 = Button(v0, text='Figura Hector Campos', command=lambda: ejecutar(mostrar(8)))
b8.grid(row=16, column=10)
b9 = Button(v0, text='Figura Jesuss Escobar', command=lambda: ejecutar(mostrar(9)))
b9.grid(row=18, column=10)
b10 = Button(v0, text='Figura Armando Hernandez', command=lambda: ejecutar(mostrar(10)))
b10.grid(row=20, column=10)
b11 = Button(v0, text='Figura Jared Garcia', command=lambda: ejecutar(mostrar(11)))
b11.grid(row=22, column=10)
v0 = mainloop()
jueves, 21 de marzo de 2019
Conjunto de figuras hechas por el grupo.
A continuación se presenta una pequeña recopilacion de algunos polígonos hechos por el grupo.
Utilizando tkMessageBox y funciones ask.
En esta ocasion se crearon ventanas de dialogo con el uso de tkMessageBox y las funciones ask.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# www.pythondiario.com
from Tkinter import *
from tkMessageBox import *
def pregunta():
askokcancel(title='cuadro,cancelar,ok',message='desea cancelar')
def devolucion():
if askyesno('Verificar', '¿Realmente quiere salir de la aplicacion?'):
showwarning('Si', 'Va a salir de la aplicacion')
else:
showinfo('No', 'usted selecciono el botton no')
def Calificacion():
if askyesno("Calificacion","tu calificacion es mayor a 70"):
showinfo("Si","Estas aprobado :D")
else:
showerror("No", "Estas reprobado:(")
def Tema():
askquestion(title="Pregunta",message="¿Te gustó el tema?")
def Cancelar():
askretrycancel(title="Cancelar",message="Reintentar o cancelar")
def Tresbotones():
askyesnocancel(title="Tres botones",message="Seleccione uno de tres botones")
Button(text='Salir', command=devolucion).pack(fill=X)
Button(text='Pregunta1', command=pregunta).pack(fill=X)
Button(text='Calificacion', command=Calificacion).pack(fill=X)
Button(text='Pregunta2', command=Tema).pack(fill=X)
Button(text='Cancelar', command=Cancelar).pack(fill=X)
Button(text='Tres botones', command=Tresbotones).pack(fill=X)
mainloop()
martes, 19 de marzo de 2019
Figura propia de corazón en Python.
En este programa se realizo una figura de un corazón hecha por mi mismo, haciendo uso de la librería Tkinter.
from Tkinter import *
def mostrar(num):
v1=Toplevel(v0)
v1.title('Ventana hija')
v1.protocol('WM_DELETE_WINDOW','onexit')
v1.config(bg='blue')
v1.geometry('800x500')
if num == 1:
hola = Canvas(v1,width=300,height=210,bg='green')
hola.pack(expand=YES,fill=BOTH)
hola.create_oval(10,10,200,200, width=5,fill='blue')
b1 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b1.grid(row=1,column=3)
if num == 2:
hola = Canvas(v1, width=300, height=300, bg='white')
hola.pack(expand=YES, fill=BOTH)
hola.create_rectangle(70,70,200,200, width=5,fill="red")
b2 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b2.grid(row=1, column=3)
if num == 3:
hola = Canvas(v1, width=300, height=300, bg='white')
hola.pack(expand=YES, fill=BOTH)
hola.create_line(70,70,200, 200, width=5, fill="red")
b3 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b3.grid(row=1, column=3)
if num == 4:
hola = Canvas(v1, width=300, height=300, bg='black')
hola.pack(expand=YES, fill=BOTH)
hola.create_line(70, 70, 200, 200, width=5, fill="red")
hola.create_line(200, 70, 70, 200, width=5, fill="gray")
b4 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b4.grid(row=1, column=3)
if num == 5:
hola = Canvas(v1, width=300, height=300, bg='white')
hola.pack(expand=YES, fill=BOTH)
hola.create_polygon(200, 15, 380, 280, 15, 100, 380, 100, 10, 280, width=5, fill="red")
b5 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b5.grid(row=1, column=3)
if num == 6:
hola = Canvas(v1, width=800, height=800, bg='white')
hola.pack(expand=YES, fill=BOTH)
hola.create_polygon(300, 300, 400, 200, 500, 200, 600, 300, 700, 200, 800, 200, 900, 300, 878, 395, 600, 700,
325, 401, fill="red", outline="brown", width=6)
b6 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b6.grid(row=1, column=3)
def Ocultar(ventana):
ventana.destroy()
def ejecutar(f):
v0.after(200,f)
v0= Tk() #Este es mi objeto ventana
v0.title('Ventana Madre')
v0.config(bg='white')
v0.geometry('500x500')
b1=Button(v0, text='Abrir ventana con circulo',command=lambda: ejecutar(mostrar(1)))
b1.grid(row=1,column=10)
b2=Button(v0, text='Abrir ventana con cuadro',command=lambda: ejecutar(mostrar(2)))
b2.grid(row=4,column=10)
b3=Button(v0, text='Hacer linea',command=lambda: ejecutar(mostrar(3)))
b3.grid(row=6,column=10)
b4=Button(v0, text='Hacer cruz',command=lambda: ejecutar(mostrar(4)))
b4.grid(row=8,column=10)
b5=Button(v0, text='Hacer poligono',command=lambda: ejecutar(mostrar(5)))
b5.grid(row=10,column=10)
b6=Button(v0, text='Hacer corazon',command=lambda: ejecutar(mostrar(6)))
b6.grid(row=12,column=10)
v0=mainloop()
miércoles, 13 de marzo de 2019
Creando figuras de linea, cruz, poligono en Python.
En este programa se crean 3 nuevas variables, una linea, una cruz y un polígono. Al polígono se le tienen que asignar muchos valores mas que a las anteriores figuras.
from Tkinter import *
def mostrar(num):
v1=Toplevel(v0)
v1.title('Ventana hija')
v1.protocol('WM_DELETE_WINDOW','onexit')
v1.config(bg='blue')
v1.geometry('500x500')
if num == 1:
hola = Canvas(v1,width=300,height=210,bg='green')
hola.pack(expand=YES,fill=BOTH)
hola.create_oval(10,10,200,200, width=5,fill='blue')
b1 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b1.grid(row=1,column=3)
if num == 2:
hola = Canvas(v1, width=300, height=300, bg='white')
hola.pack(expand=YES, fill=BOTH)
hola.create_rectangle(70,70,200,200, width=5,fill="red")
b2 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b2.grid(row=1, column=3)
if num == 3:
hola = Canvas(v1, width=300, height=300, bg='white')
hola.pack(expand=YES, fill=BOTH)
hola.create_line(70,70,200, 200, width=5, fill="red")
b3 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b3.grid(row=1, column=3)
if num == 4:
hola = Canvas(v1, width=300, height=300, bg='black')
hola.pack(expand=YES, fill=BOTH)
hola.create_line(70, 70, 200, 200, width=5, fill="red")
hola.create_line(200, 70, 70, 200, width=5, fill="gray")
b4 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b4.grid(row=1, column=3)
if num == 5:
hola = Canvas(v1, width=300, height=300, bg='white')
hola.pack(expand=YES, fill=BOTH)
hola.create_polygon(200, 15, 380, 280, 15, 100, 380, 100, 10, 280, width=5, fill="red")
b5 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b5.grid(row=1, column=3)
def Ocultar(ventana):
ventana.destroy()
def ejecutar(f):
v0.after(200,f)
v0= Tk() #Este es mi objeto ventana
v0.title('Ventana Madre')
v0.config(bg='white')
v0.geometry('500x500')
b1=Button(v0, text='Abrir ventana con circulo',command=lambda: ejecutar(mostrar(1)))
b1.grid(row=1,column=10)
b2=Button(v0, text='Abrir ventana con cuadro',command=lambda: ejecutar(mostrar(2)))
b2.grid(row=4,column=10)
b3=Button(v0, text='Hacer linea',command=lambda: ejecutar(mostrar(3)))
b3.grid(row=6,column=10)
b4=Button(v0, text='Hacer cruz',command=lambda: ejecutar(mostrar(4)))
b4.grid(row=8,column=10)
b5=Button(v0, text='Hacer poligono',command=lambda: ejecutar(mostrar(5)))
b5.grid(row=10,column=10)
v0=mainloop()
martes, 12 de marzo de 2019
Ventana madre y ventana hija.
Se realizo un programa que nos muestra como crear una ventana madre y una ventana hija incluyendo un botón para ocultar la ventana hija.
from Tkinter import *
def mostrar(num):
v1=Toplevel(v0)
v1.title('Ventana hija')
v1.protocol('WM_DELETE_WINDOW','onexit')
v1.config(bg='blue')
v1.geometry('500x500')
if num == 1:
hola = Canvas(v1,width=300,height=210,bg='green')
hola.pack(expand=YES,fill=BOTH)
hola.create_oval(10,10,200,200, width=5,fill='blue')
b3 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b3.grid(row=1,column=3)
if num == 2:
hola = Canvas(v1, width=300, height=300, bg='white')
hola.pack(expand=YES, fill=BOTH)
hola.create_rectangle(10,10,200,200, width=5,fill="red")
b3 = Button(hola, text='Ocultar', command=lambda: ejecutar(Ocultar(v1)))
b3.grid(row=1, column=3)
def Ocultar(ventana):
ventana.destroy()
def ejecutar(f):
v0.after(200,f)
v0= Tk()
v0.title('Ventana Madre')
v0.config(bg='white')
v0.geometry('500x500')
b1=Button(v0, text='Abrir ventana con circulo',command=lambda: ejecutar(mostrar(1)))
b1.grid(row=1,column=10)
b2=Button(v0, text='Abrir ventana con cuadro',command=lambda: ejecutar(mostrar(2)))
b2.grid(row=2,column=10)
v0=mainloop()
Figuras con Python.
En este programa se ve el ejemplo de unos trazos (una linea, rectángulo,
ovalo, circulo) en Python utilizando la librería Tkinter y el interpretador Pycharm.
from Tkinter import *
def linea():
canvas1 = Canvas(ventana,width=300,height=210, bg='green')
canvas1.pack(expand=YES,fill=BOTH)
canvas1.create_line(0,0,200,200)
def rectangulo():
canvas2 = Canvas(ventana,width=300,height=210, bg='green')
canvas2.pack(expand=YES,fill=BOTH)
canvas2.create_rectangle(10,10,400,200)
def ovalo():
canvas3 = Canvas(ventana,width=300,height=210, bg='green')
canvas3.pack(expand=YES,fill=BOTH)
canvas3.create_oval(10,10,400,200)
def circulo():
canvas4 = Canvas(ventana,width=300,height=210, bg='green')
canvas4.pack(expand=YES,fill=BOTH)
canvas4.create_oval(10,10,300,300)
def poligono():
canvas4 = Canvas(ventana,width=300,height=210, bg='green')
canvas4.pack(expand=YES,fill=BOTH)
canvas4.create_polygon(100,100,200,300)
ventana = Tk()
ventana.title('Mi primera aplicacion en python')
ventana.config(bg='blue')
ventana.geometry('500x500')
boton1 = Button(ventana,text='Hacer linea',command=lambda: linea())
boton1.grid(row=3,column=10)
boton2 = Button(ventana, text='Hacer rectangulo', command=lambda: rectangulo())
boton2.grid(row=4,column=10)
boton3 = Button(ventana, text='Hacer ovalo', command=lambda: ovalo())
boton3.grid(row=5,column=10)
boton4 = Button(ventana, text='Hacer circulo', command=lambda: circulo())
boton4.grid(row=6,column=10)
boton5 = Button(ventana, text='Hacer poligono', command=lambda: poligono())
boton5.grid(row=7,column=10)
ventana.mainloop()
viernes, 8 de marzo de 2019
Realizando figuras con Python.
Este programa nos sirve para hacer simples trazos como una linea y un rectángulo en Python haciendo uso de la librería Tkinter.
from Tkinter import *
def linea():
canvas1 = Canvas(ventana,width=300,height=210, bg='green')
canvas1.pack(expand=YES,fill=BOTH)
canvas1.create_line(0,0,200,200)
def rectangulo():
canvas1 = Canvas(ventana,width=300,height=210, bg='green')
canvas1.pack(expand=YES, fill=BOTH)
canvas1.create_rectangle(10,10,200,200)
ventana = Tk()
ventana.title('Mi primera aplicacion en python')
ventana.config(bg='blue')
ventana.geometry('500x500')
boton1 = Button(ventana,text='Hacer linea',command=lambda: linea())
boton1.grid(row=3,column=10)
boton2 = Button(ventana, text='Hacer rectangulo',command=lambda: rectangulo())
boton2.grid(row=4,column=10)
ventana.mainloop()
miércoles, 6 de marzo de 2019
Metodo Turtle y Tkinder.
Modulo Turtle:
Este modulo básicamente nos permite crear figuras, dibujos y gráficos con coordenadas en pantalla usando como puntero una flecha que llamamos tortuga, la cual de acuerdo a las instrucciones dadas esta caminara sobre la ventana dejando un rastro de su trayectoria.
Algunas funciones son:
Modulo Tkinder:
Este modulo básicamente nos permite crear figuras, dibujos y gráficos con coordenadas en pantalla usando como puntero una flecha que llamamos tortuga, la cual de acuerdo a las instrucciones dadas esta caminara sobre la ventana dejando un rastro de su trayectoria.
Algunas funciones son:
- forward(distance): Avanzar una determinada cantidad de píxeles.
- backward(distance): Retroceder una determinada cantidad de píxeles.
- left(angle): Girar hacia la izquierda un determinado ángulo.
- right(angle): Girar hacia la derecha un determinado ángulo.
- home(distance): Desplazarse al origen de coordenadas.
- goto((x, y)): Desplazarse a una coordenada en concreto.
- pendown(): Subir el lápiz para no mostrar el rastro.
- penup(): Bajar el lápiz para mostrar el rastro.
- shape('turtle'): Cambia al objeto tortuga.
- pencolor(color): Cambiar al color especificado.
- pensize(dimension): Tamaño de la punta del lápiz.
- fillcolor(color): Establece el color de relleno de una figura
- begin_fill(): Establece que apartir de esa linea de codigo debe pintar del color especificado la figura formada.
- end_fill():Establece que apartir de esa linea de codigo debe dejar de pintar del color especificado la figura formada.
- exitonclick(): Establece que la ventana no se debera cerrar hasta que se de un click.
- clear(): Limpia el area de trabajo, borra los trazos realizados.
Modulo Tkinder:
Tkinter es un binding de la biblioteca gráfica Tcl/Tk para el lenguaje
de programación Python, con estos queremos decir que Tk se encuentra
disponible para varios lenguajes de programación entre los cuales se
encuentra Python con el nombre de Tkinter. Este no es mas que una
adaptación de esta librería para el lenguaje Python con lo cual usar Tk
en otro lenguaje no nos supondrá un inconveniente. Se considera un
estándar para la interfaz gráfica de usuario (GUI) para Python y es el
que viene por defecto con la instalación para Microsoft Windows y
preinstalado en la mayoría de las distribuciones de GNU/Linux. Con
Tkinter podremos conseguir resultados casi tan buenos como con otras
librerías gráficas siempre teniendo en cuenta que quizás con otras
herramientas podamos realizar trabajos mas complejos donde necesitemos
una plataforma mas robusta, pero como herramienta didáctica e interfaces
sencillas nos sobrara, dándonos una perspectiva de lo que se trata el
desarrollo de una parte muy importante de una aplicación si deseamos
distribuirla. Gracias a Tkinter veremos como interactuar con el usuario
pidiéndole el ingreso de datos, capturando la pulsación de teclas,
movimientos del mouse, entre algunas de las cosas que podremos lograr.
Algunas funciones son:
- Label(): Usada para agregar etiquetas.
- Button(): Usado para agregar botones.
- grid(): Usado para establecer el posicionamiento de los elementos en ventana.
- Entry(): Utilizado para definir cajas de texto
- Pack(): Coloca los elementos en la ventana de acuerdo al modo estandar.
- geometry(): Usado para definir el tamaño de ventana.
- configure(): como su nombre lo dice es usado para configurar elementos o comportamientos de la ventana.
- mainloop(): crea un ciclo infinito que provoca que el contenido de la ventana se actualice graficamente hablando
martes, 5 de marzo de 2019
Programa zodiacal.
Se elabor un programa que te indica tu signo zodiacal.
# -*- coding: utf-8 -*-
import sys
import Tkinter as tk
from Tkinter import *
import tkMessageBox
ventana = Tk()
ventana.title("Tu signo Zodiacal ")
ventana.geometry("400x200")
ventana.config(bg="light steel blue")
vp = Frame(ventana)
vp.grid(column=0, row=0, padx=(50, 50),
pady=(10, 10)) # para posicionar cualquier objetovp.columnconfigure(0, weight=1)
vp.rowconfigure(0, weight=1)
vp.config(bg="light steel blue")
var = StringVar(vp)
ver = StringVar(vp)
var.set("Enero") # initial valuever = StringVar(ventana)
ver.set("1") # initial value
etiqueta_mes = Label(vp, text='Mes de nacimiento: ')
ent_mes = OptionMenu(vp, var, "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto",
"Septiembre", "Octubre", "Noviembre", "Diciembre", )
etiqueta_mes.grid(row=1, column=1, padx=(10, 10), pady=(10, 10), sticky=E)
ent_mes.grid(row=1, column=3)
etiqueta_dia = Label(vp, text='Fecha de nacimiento: ')
ent_dia = OptionMenu(vp, ver, "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31")
etiqueta_dia.grid(row=4, column=1, padx=(10, 10), pady=(10, 10), sticky=E)
ent_dia.grid(row=4, column=3)
def signo():
month = str(var.get())
day = int(ver.get())
if month == "Marzo" and day >= 21 or month == "Abril" and day <= 20:
tkMessageBox.showinfo("Signo ", " Aries")
elif month == "Abril" and day >= 21 or month == "Mayo" and day <= 21:
tkMessageBox.showinfo("Signo", " Tauro")
elif month == "Mayo" and day >= 22 or month == "Junio" and day <= 21:
tkMessageBox.showinfo("Signo", " Gemenis")
elif month == "Junio" and day >= 22 or month == "Julio" and day <= 22:
tkMessageBox.showinfo("Signo", " Cancer")
if month == "Julio" and day >= 23 or month == "Agosto" and day <= 23:
tkMessageBox.showinfo("Signo", " Leo")
if month == "Agosto" and day >= 24 or month == "Septiembre" and day <= 23:
tkMessageBox.showinfo("Signo", " Virgo")
if month == "Septiembre" and day >= 24 or month == "Octubre" and day <= 23:
tkMessageBox.showinfo("Signo", " Libra")
if month == "Octubre" and day >= 24 or month == "Noviembre" and day <= 22:
tkMessageBox.showinfo("Signo", "Eres Escorpion")
if month == "Noviembre" and day >= 23 or month == "Diciembre" and day <= 21:
tkMessageBox.showinfo("Signo", "Eres Sagitario")
if month == "Diciembre" and day >= 22 or month == "Enero" and day <= 20:
tkMessageBox.showinfo("Signo", "Eres Capricornio")
if month == "Enero" and day >= 21 or month == "Febrero" and day <= 18:
tkMessageBox.showinfo("Signo", "Eres Acuario")
if month == "Febrero" and day >= 19 or month == "Marzo" and day <= 20:
tkMessageBox.showinfo("Signo", "Eres Piscis")
boton = Button(vp, text='Signo', command=signo, width=20)
boton.grid(row=5, column=1, padx=(10, 10), pady=(10, 10), sticky=E)
ventana.mainloop()
Suscribirse a:
Entradas (Atom)