<s> import os <EOL> import legofy <EOL> import tkinter as tk <EOL> import tkinter . ttk as ttk <EOL> from tkinter import filedialog <EOL> import tkinter . messagebox as tkmsg <EOL> LEGO_PALETTE = ( '<STR_LIT:none>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:all>' , ) <EOL> class LegofyGui ( tk . Tk ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( ) . __init__ ( * args , ** kwargs ) <EOL> self . wm_title ( "<STR_LIT>" ) <EOL> self . iconbitmap ( os . path . dirname ( os . path . realpath ( __file__ ) ) + '<STR_LIT>' ) <EOL> self . resizable ( False , False ) <EOL> self . body = LegofyGuiMainFrame ( self ) <EOL> self . body . grid ( row = <NUM_LIT:0> , column = <NUM_LIT:0> , padx = <NUM_LIT:10> , pady = <NUM_LIT:10> ) <EOL> class LegofyGuiMainFrame ( tk . Frame ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( ) . __init__ ( * args , ** kwargs ) <EOL> self . chosenFile = None <EOL> self . chosenFilePath = tk . StringVar ( ) <EOL> self . pathField = tk . Entry ( self , width = <NUM_LIT> , textvariable = self . chosenFilePath , state = tk . DISABLED ) <EOL> self . pathField . grid ( row = <NUM_LIT:0> , column = <NUM_LIT:0> , padx = <NUM_LIT:10> ) <EOL> self . selectFile = tk . Button ( self , text = "<STR_LIT>" , command = self . choose_a_file ) <EOL> self . selectFile . grid ( row = <NUM_LIT:0> , column = <NUM_LIT:1> ) <EOL> self . groupFrame = tk . LabelFrame ( self , text = "<STR_LIT>" , padx = <NUM_LIT:5> , pady = <NUM_LIT:5> ) <EOL> self . groupFrame . grid ( row = <NUM_LIT:1> , column = <NUM_LIT:0> , columnspan = <NUM_LIT:2> , ) <EOL> self . colorPaletteLabel = tk . Label ( self . groupFrame , text = '<STR_LIT>' ) <EOL> self . colorPaletteLabel . grid ( row = <NUM_LIT:0> , column = <NUM_LIT:0> ) <EOL> self . colorPalette = ttk . Combobox ( self . groupFrame ) <EOL> self . colorPalette [ '<STR_LIT>' ] = LEGO_PALETTE <EOL> self . colorPalette . current ( <NUM_LIT:0> ) <EOL> self . colorPalette . grid ( row = <NUM_LIT:0> , column = <NUM_LIT:1> ) <EOL> self . brickNumberScale = tk . Scale ( self . groupFrame , from_ = <NUM_LIT:1> , to = <NUM_LIT:200> , orient = tk . HORIZONTAL , label = "<STR_LIT>" , length = <NUM_LIT> ) <EOL> self . brickNumberScale . set ( <NUM_LIT:30> ) <EOL> self . brickNumberScale . grid ( row = <NUM_LIT:1> , column = <NUM_LIT:0> , columnspan = <NUM_LIT:2> , ) <EOL> self . convertFile = tk . Button ( text = "<STR_LIT>" , command = self . convert_file ) <EOL> self . convertFile . grid ( row = <NUM_LIT:2> , column = <NUM_LIT:0> , columnspan = <NUM_LIT:2> ) <EOL> def choose_a_file ( self ) : <EOL> options = { } <EOL> options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> options [ '<STR_LIT>' ] = [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , ] <EOL> options [ '<STR_LIT>' ] = os . path . realpath ( "<STR_LIT:\\>" ) <EOL> options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> options [ '<STR_LIT>' ] = self <EOL> options [ '<STR_LIT:title>' ] = '<STR_LIT>' <EOL> self . chosenFile = filedialog . askopenfile ( mode = '<STR_LIT:r>' , ** options ) <EOL> if self . chosenFile : <EOL> self . chosenFilePath . set ( self . chosenFile . name ) <EOL> def convert_file ( self ) : <EOL> try : <EOL> if self . chosenFile is not None : <EOL> palette = self . colorPalette . get ( ) <EOL> if palette in LEGO_PALETTE and palette != '<STR_LIT:none>' : <EOL> legofy . main ( self . chosenFile . name , size = self . brickNumberScale . get ( ) , palette_mode = palette ) <EOL> else : <EOL> legofy . main ( self . chosenFile . name , size = self . brickNumberScale . get ( ) ) <EOL> tkmsg . showinfo ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> else : <EOL> tkmsg . showerror ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> except Exception as e : <EOL> tkmsg . showerror ( "<STR_LIT>" , str ( e ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app = LegofyGui ( ) <EOL> app . mainloop ( ) </s>
