|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +""" |
| 4 | +Created on Fri Oct 4 15:18:09 2019 |
| 5 | +
|
| 6 | +@author: ashish |
| 7 | +""" |
| 8 | +import tkinter as tk |
| 9 | +import SIC as s |
| 10 | +import XE as x |
| 11 | + |
| 12 | +output = '' #sic global variables |
| 13 | +op="" |
| 14 | +operand="" |
| 15 | +address="" |
| 16 | + |
| 17 | +output1 = '' #sic_xe global variables |
| 18 | +op1="" |
| 19 | +operand1="" |
| 20 | +address1="" |
| 21 | +pc="" |
| 22 | +b="" |
| 23 | + |
| 24 | + |
| 25 | +def clear_sic(): |
| 26 | + global op |
| 27 | + global operand |
| 28 | + global address |
| 29 | + global output |
| 30 | + op.delete(0,tk.END) |
| 31 | + operand.delete(0,tk.END) |
| 32 | + address.delete(0,tk.END) |
| 33 | + output.config(text="Enter the Inputs") |
| 34 | + |
| 35 | + |
| 36 | +def clear_sicxe(): |
| 37 | + global op1 |
| 38 | + global operand1 |
| 39 | + global address1 |
| 40 | + global pc |
| 41 | + global b |
| 42 | + global output1 |
| 43 | + op1.delete(0,tk.END) |
| 44 | + operand1.delete(0,tk.END) |
| 45 | + address1.delete(0,tk.END) |
| 46 | + pc.delete(0,tk.END) |
| 47 | + b.delete(0,tk.END) |
| 48 | + output1.config(text="Enter the Inputs") |
| 49 | + |
| 50 | +def sic(): |
| 51 | + sub = tk.Tk() #create window |
| 52 | + sub.title("SIC") |
| 53 | + L1 = tk.Label(sub, text = "Mnemonic opcode",font=("Bitstream Charter",15," bold")) |
| 54 | + L1.place(x=254,y=270 ) |
| 55 | + global op |
| 56 | + op=tk.Entry(sub,font=("Bitstream Charter",14," bold"),width=15) |
| 57 | + op.place(x=256,y=300) |
| 58 | + L2 = tk.Label(sub, text = "Operand",font=("Bitstream Charter",15," bold")) |
| 59 | + L2.place(x=595,y=270 ) |
| 60 | + global operand |
| 61 | + operand=tk.Entry(sub,font=("Bitstream Charter",14," bold"),width=15) |
| 62 | + operand.place(x=553,y=300) |
| 63 | + L3= tk.Label(sub, text = "Operand Address",font=("Bitstream Charter",15," bold")) |
| 64 | + L3.place(x=859,y=270 ) |
| 65 | + global address |
| 66 | + address=tk.Entry(sub,font=("Bitstream Charter",14," bold"),width=15) |
| 67 | + address.place(x=857,y=300) |
| 68 | + button1 = tk.Button(sub,text='GENERATE',bg="green",fg="white",font=("Courier 10 Pitch",17,"bold ")\ |
| 69 | + ,width=10,height=1,border=2,relief="raised",command=update_answer_sic) |
| 70 | + button1.place(x=550,y=400) |
| 71 | + button2 = tk.Button(sub,text='CLEAR',bg="red",fg="white",font=("Courier 10 Pitch",17,"bold ")\ |
| 72 | + ,width=10,height=1,border=2,relief="raised",command=lambda :clear_sic()) |
| 73 | + button2.place(x=550,y=450) |
| 74 | + L4= tk.Label(sub, text = "NOTE: Enter empty field with '-'",font=("Bitstream Charter",15,"bold italic"),fg="red") |
| 75 | + L4.place(x=500,y=350 ) |
| 76 | + global output |
| 77 | + output=tk.Label(sub,text="Enter the Inputs",width=38,font=("Courier 10 Pitch",25,"bold italic"),bg="black",fg="green") |
| 78 | + output.place(x=260,y=140) |
| 79 | + sub.mainloop() |
| 80 | + |
| 81 | +def update_answer_sic(): |
| 82 | + global op |
| 83 | + global operand |
| 84 | + global address |
| 85 | + result=s.call1(op.get(),operand.get(),address.get()) |
| 86 | + global output |
| 87 | + output.config(text='{}'.format(result)) |
| 88 | + |
| 89 | +def sicxe(): |
| 90 | + sub1 = tk.Tk() #create window |
| 91 | + sub1.title("SIC/XE") |
| 92 | + L1 = tk.Label(sub1, text = "Mnemonic opcode",font=("Bitstream Charter",15," bold")) |
| 93 | + L1.place(x=45,y=270 ) |
| 94 | + global op1 |
| 95 | + op1=tk.Entry(sub1,font=("Bitstream Charter",14," bold"),width=15) |
| 96 | + op1.place(x=50,y=300) |
| 97 | + L2 = tk.Label(sub1, text = "Operand",font=("Bitstream Charter",15," bold")) |
| 98 | + L2.place(x=345,y=270 ) |
| 99 | + global operand1 |
| 100 | + operand1=tk.Entry(sub1,font=("Bitstream Charter",14," bold"),width=15) |
| 101 | + operand1.place(x=305,y=300) |
| 102 | + L3 = tk.Label(sub1, text = "Operand Address",font=("Bitstream Charter",15," bold")) |
| 103 | + L3.place(x=550,y=270 ) |
| 104 | + global address1 |
| 105 | + address1=tk.Entry(sub1,font=("Bitstream Charter",14," bold"),width=15) |
| 106 | + address1.place(x=550,y=300) |
| 107 | + L4= tk.Label(sub1, text ="PC address" ,font=("Bitstream Charter",15," bold")) |
| 108 | + L4.place(x=850,y=270 ) |
| 109 | + global pc |
| 110 | + pc=tk.Entry(sub1,font=("Bitstream Charter",14," bold"),width=15) |
| 111 | + pc.place(x=825,y=300) |
| 112 | + L5= tk.Label(sub1, text ="Base address" ,font=("Bitstream Charter",15," bold")) |
| 113 | + L5.place(x=1105,y=270 ) |
| 114 | + global b |
| 115 | + b=tk.Entry(sub1,font=("Bitstream Charter",14," bold"),width=15) |
| 116 | + b.place(x=1080,y=300) |
| 117 | + button1 = tk.Button(sub1,text='GENERATE',bg="green",fg="white",font=("Courier 10 Pitch",17,"bold "),\ |
| 118 | + width=10,height=1,border=2,relief="raised",command=update_answer_xe) |
| 119 | + button1.place(x=550,y=400) |
| 120 | + button2 = tk.Button(sub1,text='CLEAR',bg="red",fg="white",font=("Courier 10 Pitch",17,"bold ")\ |
| 121 | + ,width=10,height=1,border=2,relief="raised",command=lambda :clear_sicxe()) |
| 122 | + button2.place(x=550,y=450) |
| 123 | + L6= tk.Label(sub1, text = "NOTE: Enter empty field with '-'",font=("Bitstream Charter",15,"bold italic"),fg="red") |
| 124 | + L6.place(x=500,y=350 ) |
| 125 | + global output1 |
| 126 | + output1=tk.Label(sub1,text="Enter the Inputs",width=39,font=("Courier 10 Pitch",25,"bold italic"),bg="black",fg="green") |
| 127 | + output1.place(x=260,y=140) |
| 128 | + sub1.mainloop() |
| 129 | + |
| 130 | +def update_answer_xe(): |
| 131 | + global op1 |
| 132 | + global operand1 |
| 133 | + global address1 |
| 134 | + global pc |
| 135 | + global b |
| 136 | + result=x.call2(op1.get(),operand1.get(),address1.get(),pc.get(),b.get()) |
| 137 | + global output1 |
| 138 | + output1.config(text='{}'.format(result)) |
| 139 | + |
| 140 | + |
| 141 | +if __name__== "__main__" : |
| 142 | + root = tk.Tk() #create window |
| 143 | + root.title("OCG") #title |
| 144 | + background = tk.PhotoImage(file="background.png") |
| 145 | + w1 = tk.Label(root, image=background) #background image |
| 146 | + w1.place(x=0,y=0,relwidth=1,relheight=1) |
| 147 | + logo= tk.PhotoImage(file="designer.png") |
| 148 | + w2 = tk.Label(root, image=logo,bg="white",anchor='nw',fg="black",text="OBJECT CODE GENERATOR",compound = "left",font=("Courier 10 Pitch",35,"bold italic"),padx=10,pady=5).pack(fill="both") |
| 149 | + button_image= tk.PhotoImage(file="binary-code.png") |
| 150 | + button1 = tk.Button(root,image=button_image,text='SIC',width=200,height=200,bg="white",font=("Courier 10 Pitch",25,"bold "),compound="left",border=20,relief="groove",command=lambda :sic()) |
| 151 | + button1.place(x=270,y=250) |
| 152 | + button2 = tk.Button(root,image=button_image,text='SIC/XE',width=200,height=200,bg="white",font=("Courier 10 Pitch",25,"bold"),compound="left",border=20,relief="groove",command=lambda :sicxe()) |
| 153 | + button2.place(x=720,y=250) |
| 154 | + student=tk.PhotoImage(file="man.png") |
| 155 | + w4=tk.Label(root,text="Ashish M J\n4NI17IS017",image=student,font=("Bitstream Charter",15,"italic bold"),bg="white",compound="left",padx=10,pady=5,anchor="s",width=770) |
| 156 | + w4.place(x=250,y=650) |
| 157 | + root.mainloop() |
| 158 | + |
| 159 | + |
0 commit comments