So sortieren Sie eine Liste über zwei FramesPython

Python-Programme
Anonymous
 So sortieren Sie eine Liste über zwei Frames

Post by Anonymous »

Ist es möglich, mithilfe einer Liste 0:5 nach Bild 1 und 5:10 nach Bild 2 zu sortieren?
Jetzt werden beide Optionsfelder in Bild 1 und 2 angeklickt. Ich möchte, dass jeweils nur eines ausgewählt werden kann.
Mein Code:

Code: Select all

import tkinter as tk
from tkinter import *

List1 = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]

List2 = List1[ 5: ]
List1 = List1[ :5 ]

window = Tk()
window.geometry( "300x300" )

x = tk.IntVar()
x.set( 'none' )

frame_1 = LabelFrame( window, text="Label Frame 1" )
frame_2 = LabelFrame( window, text="Label Frame 2" )
frame_1.grid( row=0, column=0, sticky='nsew' )
frame_2.grid( row=0, column=1, sticky='nsew' )

for index in range( len(List1) ):
radiobutton = Radiobutton( frame_1, text = List1[index], variable = x, value = index)
radiobutton.pack( anchor = 'nw' )

for index in range( len(List2) ):
radiobutton = Radiobutton( frame_2, text = List2[index], variable = x, value = index )
radiobutton.pack( anchor = 'nw' )

window.columnconfigure( (0, 1), weight = 1, uniform = 'a' )
window.rowconfigure( (0), weight = 1 )
window.mainloop()

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post