I'm trying to test a calendar I'll be using in a bigger aspect of a program, but I'm having trouble even getting it to work. I'm using python 2.7 (before anyone asks me to upgrade to 3.x, I'm using it for reasons of also using older libraries, and it's only for a course project so has no real work applications) on Windows 10, and whatever I run the program in (PyScripter, IDLE), it keeps coming back saying:
ImportError: No module named tkinter
As far as I have come to understand, Tkinter is part of Python itself, so should not really be having this problem, even in 2.7.
The code I am using was actually used by someone else trying to get a calendar to function, and I used it and tweaked it so it would only show the weekdays (the program I'm making doesn't require them, so I'm trying to omit them from the code), but as I can't even get it to run, I'm at a loss of how to make it go. If anyone can even suggest how to go about another way to make a calendar gui not show weekends, or even just grey them out so they'd not be selectable, I'd be grateful for that, too
Here is the code I'm testing:
from tkinter import *
from calendar import *
class Application(Frame):
def __init__(self, master):
Frame.__init__(self, master)
self.grid()
year = int(raw_input('\nEnter Year eg. 2017\n'))
month = int(raw_input('\nEnter month number.\n'))
self.create_widgets(year, month)
def create_widgets(self, year, month):
days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']
#create labels
for i in range(7):
label = Label(self, text=days[i])
label.grid(row = 0, column = i)
weekday, numDays = monthrange(year, month)
week = 1
for i in range(1, numDays + 1):
button = Button(self, text = str(i))
button.grid(row = week, column = weekday)
weekday += 1
if weekday > 4:
week += 1
weekday = 0
mainWindow = tk()
obj = Application(root)
mainWindow.mainloop()