2

I'm making a python application that is (hopefully) OS agnostic. This is being written in python3.7 and the GUI is being constructed from Tkinter8.6. I am attempting to use platform.system() for determining the OS family.

I am setting the tkinter border fullscreen with one of two commands depending on the OS.The problem is I dont understand what platform should print for MacOS.

The code I am using will roughly look like this:

from tkinter import *
from tkinter import ttk
import platform

root = Tk()
system = platform.system()

if system == 'Windows':
    root.state('zoomed')
elif system == 'Linux' or system == 'Darwin':
    root.attributes('-zoomed', True)
elif system == '':
    expectation = "Expected: 'Linux' 'Windows' or 'Darwin', Received: "
    raise OSError(expectation + system)

Peoples examples and the docs are conflicting and I dont have a Mac to test it on.

  • The docs say: "Returns the system/OS name, e.g. 'Linux', 'Windows', or 'Java'..."

  • What several peoples posts keep repeating: "will return darwin for MacOS"

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Alan-Cugler
  • 133
  • 1
  • 2
  • 10

1 Answers1

4

You are using the platform library (platform.system() == 'Darwin'). The post you linked to uses the sys library (sys.platform == 'darwin'). With the library you are using, the string is 'Darwin'. I hope that helps.

ryan28561
  • 302
  • 2
  • 11