{ "metadata": { "name": "chapter-17.ipynb" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "

Chapter 17: Windows Programming

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Message Box, Page number: 563

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from tkinter import *\n", "\n", "\n", "#creating window\n", "root = Tk()\n", "root.title(\"Press Me\")\n", "button1 = Button(root, text=\"Press Me\") #creating button\n", "button1.pack()\n", "import ctypes #creating message box\n", "MessageBox = ctypes.windll.user32.MessageBoxW\n", "MessageBox(None, 'Hi!', 'Waiting', 0)\n", "root.mainloop()\n" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

More Windows, Page number: 566

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from tkinter import *\n", "root = []\n", "#creating windows\n", "for x in range(0,10):\n", " root.append(Tk())\n", " root[x].title(\"Press Me\")\n", " button1 = Button(root[x], text=\"Press Me\") #creating button\n", " button1.pack()\n", " \n", "import ctypes #creating message box\n", "MessageBox = ctypes.windll.user32.MessageBoxW\n", "MessageBox(None, 'Hi!', 'Waiting', 0)\n" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

A Real World Window, Page number: 568

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from tkinter import *\n", "\n", "\n", "class Example(Frame):\n", " def __init__(self, parent):\n", " Frame.__init__(self, parent)\n", "\n", " self.display = Canvas(self, width=700, height=200)\n", " self.display.pack(side=\"top\", fill=\"both\", expand=True)\n", " \n", "if __name__ == \"__main__\":\n", " root = Tk()\n", " root.title(\"Title\")\n", " Frame = Example(parent=root)\n", " Frame.pack(side=\"top\", fill=\"both\", expand=True)\n", " root.mainloop()\n" ], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }