Access state of object (tkinter, Python3) beginner's level

时间:2016-02-12 20:19:20

标签: python checkbox tkinter state

What I want to get: change of checkbox state changes the state of the Entry widget from 'disabled' into 'normal'. (checkbox off = Entry disabled, checkbox on = Entry normal). My problem is that I don't know how to access and update the state of entry.

My code:

<?php

$connection = mysql_connect('#', '#', '#')
    or die('Could not connect: ' .mysql_error());
mysql_select_db('#');

$equipmentquery="UPDATE tbl_assets SET date_installed = curdate(), account_number = {$_GET['0']} WHERE serial = $_POST['job']";

$techquery="UPDATE tbl_assets SET date_installed = curdate(), account_number = {$_GET ['0']} WHERE serial = $_POST['tech']";

?>

I'm beginner, so I'd be especially grateful for simple solutions.

1 个答案:

答案 0 :(得分:1)

Save a reference to the entry widget, then call the map method. To make things easy, give your checkbutton the values for the states. That isn't strictly necessary, you can use a boolean and then translate that to the appropriate state.

configure

Note: you need to call def create_checkbox(self): self.limit = StringVar(value="normal") checkbutton = Checkbutton(..., onvalue="normal", offvalue="disabled", ...) checkbutton.grid(...) def create_entry(self): self.entry_low = StringVar() self.entry = Entry(self, width=6, textvariable=self.entry_low, state='disabled', ) self.entry.grid(row=1, column=2, sticky=W) def state_update(self): self.entry.config(state="normal") #THIS OBVIOUSLY DOES NOT WORK in a second step. grid (as well as grid(...)) returns place. If you do None, x=Entry(...).grid(...) will always be x.

相关问题