Advertisement
berg

obj2pie.py

Nov 2nd, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.77 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #-----------------------------------------------------------------------------
  3. # Name:        panel.py
  4. # Purpose:     simplify obj2pie options
  5. #
  6. # Author:      <Berg>
  7. #
  8. # Created:     2011/10/31
  9. # RCS-ID:      $Id: panel.py $
  10. # Copyright:   (c) 2006
  11. # Licence:     <your licence>
  12. #-----------------------------------------------------------------------------
  13.  
  14. from Tkinter import *
  15. import Tkinter
  16. import tkMessageBox
  17. import tkFileDialog
  18. import os
  19.  
  20. # a place to store our filename
  21. objectfile=''
  22. piefile=''
  23. texturefile=''
  24. yaxis=''
  25. reverswind=''
  26. mask=''
  27. pie=''
  28. slider='-s 0 '
  29. global path
  30. path = 'C:\\your\\file\\path\\to\\obj2pie.exe'
  31.  
  32. top = Tkinter.Tk()
  33. top.title("Object to Pie Converter")
  34. top.geometry('550x300+100+100')#geometry window size
  35.  
  36. #Pick a file and store it in global variable objectfile
  37. def ObjectFile():
  38.     global objectfile  # use global variable
  39.     objectfile = tkFileDialog.askopenfilename()
  40.     return
  41.  
  42. def PieFile():
  43.     global piefile  # use global variable
  44.     piefile = tkFileDialog.asksaveasfilename()#this should be a save file browers not open ..pie to save to
  45.     return
  46.  
  47. def TextureFile():
  48.     global texturefile  # use global variable
  49.     file2 = tkFileDialog.askopenfilename()#this should be texture only
  50.     texturefile=os.path.basename(file2)
  51.     return
  52. def SetY():
  53.     global yaxis
  54.     yaxis = '-y '
  55.     return
  56. def UnSetY():
  57.     global yaxis
  58.     yaxis = ''
  59.     return
  60. def Revers():
  61.     global reverswind
  62.     reverswind = '-r '
  63.     return
  64. def UnRevers():
  65.     global reverswind
  66.     reverswind = ''
  67.     return
  68. def Mask():
  69.     global mask
  70.     mask = '-m '
  71.     return
  72. def UnMask():
  73.     global mask
  74.     mask = ''
  75.     return
  76. def PieThree():
  77.     global pie
  78.     pie = '-v 3 '
  79.     return
  80. def PieTwo():
  81.     global pie
  82.     pie = '-v 2 '
  83.     return
  84. def SliderNumber(num):
  85.     global slider
  86.     slider = '-s ' + num + ' '
  87.     return
  88. #-----------------------------------------------------------------------------------------------------------------------
  89. #-------------------showing what output
  90. def CallBack(): #define a command for a button
  91.  
  92.     tkMessageBox.showinfo( "show file ", " This is the file selected \r\n" + path + " -y -v 3 -r -s 8 " + objectfile + " " + piefile + " " + texturefile ) #open another message box with this info in
  93.  
  94.     os.system(path + " " + slider + mask + pie + reverswind + yaxis + objectfile + " " + piefile + " " + texturefile )
  95.  
  96.     print path + " " + slider + mask + pie + reverswind + yaxis + objectfile + " " + piefile + " " + texturefile
  97.  
  98. #-----------------------------------------------------------------------------------------------------------------------
  99. #-------------------end what output
  100.  
  101.  
  102. v = IntVar()
  103.  
  104. Radiobutton(top, text="Y is Up       ", variable=v, value=1, command = SetY).place(x=20, y=20)
  105. Radiobutton(top, text="Leave Y as is ", variable=v, value=2, command = UnSetY).place(x=250, y=20)
  106. label=Label(text='<--select for -y').place(x=150, y=20)
  107. w = IntVar()
  108. Radiobutton(top, text="Revers Winding", variable=w, value=1, command = Revers).place(x=20, y=40)
  109. Radiobutton(top, text="leave -r off  ", variable=w, value=2, command = UnRevers).place(x=250, y=40)
  110. label1=Label(text='<--select for -r').place(x=150, y=40)
  111. x = IntVar()
  112. Radiobutton(top, text="Enable Tcmask ", variable=x, value=1, command = Mask).place(x=20, y=60)
  113. Radiobutton(top, text="No Tcmask     ", variable=x, value=2, command = UnMask).place(x=250, y=60)
  114. label2=Label(text='<--select for -m').place(x=150, y=60)
  115. y = IntVar()
  116. Radiobutton(top, text="Pie 3         ", variable=y, value=1, command = PieThree).place(x=20, y=80)
  117. Radiobutton(top, text="Pie 2         ", variable=y, value=2, command = PieTwo).place(x=250, y=80)
  118.  
  119. sliderscale = Scale(top, from_=-100, to=100, orient=HORIZONTAL, command = SliderNumber)
  120. label3=Label(text='slide to adjust model size +/- \r\nDo not set on 0 as size x 0 = 0').place(x=250, y=105)
  121. global num
  122. num=sliderscale.get()
  123. sliderscale['bg']='cyan'
  124. sliderscale.place(x=100, y=110)
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. mybutton1 = Tkinter.Button(top, text ="input file.obj", command = ObjectFile)
  135. mybutton2 = Tkinter.Button(top, text ="output file.pie", command = PieFile)
  136. mybutton3 = Tkinter.Button(top, text ="Model Texture.png", command = TextureFile)
  137. mybutton = Tkinter.Button(top, text ="Convert", command = CallBack)
  138. mybutton['bg']='orange'
  139. exitbutton = Tkinter.Button(top, text ="Exit", command=top.destroy)
  140. #label=Label(text='Usage: obj2pie [options] input_filename output_filename texturefilename').place(row=11, column=2)
  141. #label2=Label(text= '-y     Do not swap Y and Z axis. Exporter uses Y-axis as "up".').place(row=12, column=2)
  142.  
  143.  
  144.  
  145. mybutton1.place(x=20, y=200)
  146. mybutton2.place(x=150, y=200)
  147. mybutton3.place(x=280, y=200)
  148. mybutton.place(x=20, y=260)
  149. exitbutton.place(x=370, y=260)
  150.  
  151.  
  152.  
  153. top.mainloop()
  154.  
  155.  
  156.  
  157.  
  158. if __name__ == '__main__':
  159.     pass # add a call to run your script here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement