2016-09-16 5 views
1

저는 파이썬 2.7에서 Tkinter를 사용하여 프레임을 만들고 다른 배경을 얻었습니다!프레임의 배경을 변경하는 방법 - Tkinter!

_tkinter.TclError: unknown option "-bg" 

및 전체 역 추적 :

Traceback (most recent call last): 
    File "//MCLSERVER4/MCL Sicherung/M.Grbic/Python/Power Cycling Test/pwrMultiCycling.py", line 26, in <module> 
    gui = Interface(root) 
    File "//MCLSERVER4/MCL Sicherung/M.Grbic/Python/Power Cycling Test/pwrMultiCycling.py", line 20, in __init__ 
    self.frame = Frame(parent, bg='', colormap='new') 
    File "S:\Python27\lib\lib-tk\ttk.py", line 735, in __init__ 
    Widget.__init__(self, master, "ttk::frame", kw) 
    File "S:\Python27\lib\lib-tk\ttk.py", line 555, in __init__ 
    Tkinter.Widget.__init__(self, master, widgetname, kw=kw) 
    File "S:\Python27\lib\lib-tk\Tkinter.py", line 2036, in __init__ 
    (widgetName, self._w) + extra + self._options(cnf)) 
_tkinter.TclError: unknown option "-bg" 

내 코드 :

from Tkinter import * 
from ttk import * 
import os 
from PIL import Image 

class Interface: 

    def __init__(self, parent): 
     self.parent = parent 
     parent.title("") 
     local_directory = os.path.dirname(os.path.realpath(__file__)) 
     self.dataname = "/does/not/exist" 

     self.frame = Frame(parent, bg='', colormap='new') 



if __name__ == '__main__': 
    root = Tk() 
    gui = Interface(root) 
    root.mainloop() 
+2

위험 * 수입품. 그 솔루션 tk와 ttk와 –

+0

내 문제를 해결할 수 없습니다. –

답변

1

내가 생각하기에, 내가 해결책을 가지고이 코드를 사용할 때, 다음과 같은 오류를 제공 그리고 내 문제는 다음과 같습니다 :

import Tkinter 
from ttk import * 
import os 

    class Interface: 

     def __init__(self, parent): 
      self.parent = parent 
      parent.title("") 

      self.frame = Tkinter.Frame(parent, bg='', colormap='new') 


    if __name__ == '__main__': 
     root = Tkinter.Tk() 
     gui = Interface(root) 
     root.mainloop() 
관련 문제