Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Working with the calendar widget in PyQt4
Forum Updated to NodeBB v4.3 + New Features

Working with the calendar widget in PyQt4

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 739 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JapieK
    wrote on last edited by JapieK
    #1

    Hi,

    I'm trying to create a small program that allows my wife to quickly select a date and then select the type of shift she had to work at the hospital. Here's an image:

    https://imgur.com/a/ga6PB

    The idea is that after she selects a date, a shift, and presses Save, the selected cell of the date is given a certain color to easily indicate that she's already selected a shift for that date. Then she continues to the next one, etc. (Even better would be if she could double-click the date after which a dropdown menu appears in the cell that allows her to select either d (for day), e (for evening), or n (for night), but that is way out of my league) programming-wise).

    Finally, when she presses Excel or PDF, all her hours and irregular hours are displayed in a neat order. I already managed that last part with a boring old python console program. I wanted to spice it up with a fancy GUI and figured a calendar would do nicely.

    But I have no experience whatsoever when it comes to C++, Javascript, etc, and every example of the calendar widget appears to be in those programming languages. I've tried for 4 hours now and I can't seem to figure out how to color the selected cell upon pressing the save button.

    I used the Qt Designer to create the layout and this is the output after using pyuic4: https://pastebin.com/raw/am9EeCcz (the file is called test.py)
    Then I use this to run the program: https://pastebin.com/raw/y0zGEgJm (this file is called test2.py). The Save button is already able to gather the selected date and shift, but now it needs to colorize the selected date as well.

    Can anyone give me a hand or point me to an example that uses Python instead of C++ or Javascript?

    Thank you in advance!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      From a quick look at QCalendarWidget, you'll likely want to use setDateTextFormat to modify the appearance of a given date.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved