python缩进格式错误修改_在python tkinter上获取奇怪的缩进错误-unindent与任何外部缩进级别都不匹配...

我只是添加了1个def和2行代码,然后才得到缩进错误。我正在尝试修改从页面生成的代码

Tkinter

登录消息框的GUI编辑器。我真的不知道为什么会这样。

我做的代码和

this guy on youtube

我试图把DEF移到最左边,也不是最右边。

所以我想补充的是。

def cancelLogin()

在登录页类中。它向我显示了上的缩进错误

def init()

. 请帮我弄清楚。

#! /usr/bin/env python

# -*- coding: utf-8 -*-

#

# GUI module generated by PAGE version 4.20

# in conjunction with Tcl version 8.6

# Feb 07, 2019 05:38:55 AM EST platform: Linux

import sys

import tkMessageBox

try:

import Tkinter as tk

except ImportError:

import tkinter as tk

try:

import ttk

py3 = False

except ImportError:

import tkinter.ttk as ttk

py3 = True

import jta_support

def vp_start_gui():

'''Starting point when module is the main routine.'''

global val, w, root

root = tk.Tk()

top = Login_page (root)

jta_support.init(root, top)

root.mainloop()

w = None

def create_Login_page(root, *args, **kwargs):

'''Starting point when module is imported by another program.'''

global w, w_win, rt

rt = root

w = tk.Toplevel (root)

top = Login_page (w)

jta_support.init(w, top, *args, **kwargs)

return (w, top)

def destroy_Login_page():

global w

w.destroy()

w = None

class Login_page:

def cancelLogin(self):

msg=tkMessageBox.askyesno("Login page","Are you sure , you want to cancel login?")

def __init__(self, top=None):

'''This class configures and populates the toplevel window.

top is the toplevel containing window.'''

_bgcolor = '#d9d9d9' # X11 color: 'gray85'

_fgcolor = '#000000' # X11 color: 'black'

_compcolor = '#d9d9d9' # X11 color: 'gray85'

_ana1color = '#d9d9d9' # X11 color: 'gray85'

_ana2color = '#ececec' # Closest X11 color: 'gray92'

font11 = "-family {DejaVu Sans} -size 10 -weight bold -slant " \

"roman -underline 0 -overstrike 0"

font17 = "-family {DejaVu Sans} -size 13 -weight bold -slant " \

"roman -underline 0 -overstrike 0"

self.style = ttk.Style()

if sys.platform == "win32":

self.style.theme_use('winnative')

self.style.configure('.',background=_bgcolor)

self.style.configure('.',foreground=_fgcolor)

self.style.configure('.',font="TkDefaultFont")

self.style.map('.',background=

[('selected', _compcolor), ('active',_ana2color)])

top.geometry("584x457+1039+55")

top.title("JTA Login")

top.configure(relief="ridge")

top.configure(background="#201856")

top.configure(highlightbackground="#000000")

self.btnLogin = tk.Button(top)

self.btnLogin.place(relx=0.634, rely=0.744, height=54, width=101)

self.btnLogin.configure(background="#201856")

self.btnLogin.configure(borderwidth="0")

self.btnLogin.configure(font=font11)

self.btnLogin.configure(highlightbackground="#201856")

self._img1 = tk.PhotoImage(file="../../Downloads/button.png")

self.btnLogin.configure(image=self._img1)

self.btnLogin.configure(padx="6m")

self.btnLogin.configure(pady="3m")

self.btnLogin.configure(text='''Login''')

self.btnLogin.configure(width=101)

self.btnExit = tk.Button(top)

self.btnExit.place(relx=0.223, rely=0.744, height=55, width=97)

self.btnExit.configure(activebackground="#ffffff")

self.btnExit.configure(background="#201856")

self.btnExit.configure(borderwidth="0")

self.btnExit.configure(font=font11)

self.btnExit.configure(highlightbackground="#201856")

self._img2 = tk.PhotoImage(file="../../Downloads/button(1).png")

self.btnExit.configure(image=self._img2)

self.btnExit.configure(padx="6m")

self.btnExit.configure(pady="3m")

self.btnExit.configure(text='''Exit''')

self.btnExit.configure(width=97)

self.txtUsername = tk.Entry(top)

self.txtUsername.place(relx=0.462, rely=0.372, height=40, relwidth=0.342)

self.txtUsername.configure(background="white")

self.txtUsername.configure(font="TkFixedFont")

self.txtPassword = tk.Entry(top)

self.txtPassword.place(relx=0.462, rely=0.547, height=40, relwidth=0.342)

self.txtPassword.configure(background="white")

self.txtPassword.configure(font="TkFixedFont")

self.txtPassword.configure(selectbackground="#c4c4c4")

self.Label1 = tk.Label(top)

self.Label1.place(relx=0.205, rely=0.372, height=40, width=100)

self.Label1.configure(background="#201856")

self.Label1.configure(font=font17)

self.Label1.configure(foreground="#ffffff")

self.Label1.configure(text='''Username''')

self.Label1_3 = tk.Label(top)

self.Label1_3.place(relx=0.205, rely=0.547, height=40, width=100)

self.Label1_3.configure(activebackground="#f9f9f9")

self.Label1_3.configure(background="#201856")

self.Label1_3.configure(font=font17)

self.Label1_3.configure(foreground="#ffffff")

self.Label1_3.configure(text='''Password''')

self.menubar = tk.Menu(top,font="TkMenuFont",bg=_bgcolor,fg=_fgcolor)

top.configure(menu = self.menubar)

self.TLabel1 = ttk.Label(top)

self.TLabel1.place(relx=0.154, rely=0.022, height=131, width=423)

self.TLabel1.configure(background="#201856")

self.TLabel1.configure(foreground="#000000")

self.TLabel1.configure(font="TkDefaultFont")

self.TLabel1.configure(relief='flat')

self.TLabel1.configure(text='''Tlabel''')

self.TLabel1.configure(width=423)

self._img3 = tk.PhotoImage(file="./jtalogo.png")

self.TLabel1.configure(image=self._img3)

if __name__ == '__main__':

vp_start_gui()

如果没有“def cancelogin()”,它可以像往常一样正常工作。

实际结果:

文件“./jta.py”,第52行

DEF

初始化

(self,top=无):

^

缩进错误:取消缩进与任何外部缩进级别都不匹配

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值