Skip to content

Added open_window usage example#770

Open
Nadiazahan wants to merge 4 commits into
thoth-tech:mainfrom
Nadiazahan:create-open-window-example
Open

Added open_window usage example#770
Nadiazahan wants to merge 4 commits into
thoth-tech:mainfrom
Nadiazahan:create-open-window-example

Conversation

@Nadiazahan
Copy link
Copy Markdown

Description

Splashkit Function: open_window

Overview of example functionality: This example demonstrates how to use the open_window function to create a simple window and display basic text and shapes on the screen. It provides a beginner-friendly introduction to opening and refreshing a SplashKit window.

Example Output:

image

Files Included

  • C++ code
  • C# code (Top-Level statements)
  • C# code (Object-Oriented Programming)
  • Python code
  • Relevant title for the example (.txt)
  • Screenshot

Usage Example Checks

  • Code uses Splashkit function above
  • Code does not use non-Splashkit functions
  • Code does not use extra function declarations or extra classes
  • Code does not violate any of the Thoth Tech SplashKit Style Guide rules
  • Simple, clear demonstration of the function
  • Tested in Chrome and Firefox

@netlify
Copy link
Copy Markdown

netlify Bot commented May 14, 2026

Deploy Preview for splashkit failed.

Name Link
🔨 Latest commit 47390ce
🔍 Latest deploy log https://app.netlify.com/projects/splashkit/deploys/6a072849fa886d0008e5cad9

Copy link
Copy Markdown

@himanshigaba22 himanshigaba22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice first contribution - the example is simple and easy to understand 👍

Just a few quick fixes:

  • The .txt file should only be one line (just the title)
  • Add using static SplashKitSDK.SplashKit; in the C# top-level file
  • Use function-style colours like color_black() instead of COLOR_BLACK or Color.SKY_BLUE
  • Add close_all_windows() in the C++ version
  • In Python, use refresh_screen_with_target_fps(60)

Also, can you confirm if usage-example-references.json has been updated?

Once these are fixed, it should be good to go 👍

@anandika-nair
Copy link
Copy Markdown

This is a clear beginner-friendly example and the visual output demonstrates open_window nicely, but I noticed a few important changes needed before merge. Similar to the feedback of [himanshigaba22] the .txt file should only contain the title, the C# top-level example should follow the usual usage example format, and the language-specific style conventions (such as colour usage and refresh functions .should be kept consistent with existing SplashKit examples. The C++ version should also include proper cleanup at the end. One major thing I noticed is the lack of code comments, since usage examples are meant to help beginners understand not just what the code does but how to use the function, adding simple explanatory comments across the examples would make this much more useful.

@Nadiazahan
Copy link
Copy Markdown
Author

@himanshigaba22 @anandika-nair Thanks both for the feedback! I’ve now updated the example by fixing the .txt file so it only contains a single line title, adding using static SplashKitSDK.SplashKit; to the C# top-level example, updating the colour usage to function-style colours like color_black() where required instead of COLOR_BLACK or Color.SKY_BLUE, changing the Python version to use refresh_screen_with_target_fps(60), and adding close_all_windows() in the C++ version.

I also updated the usage-example-references.json file by creating a new windows section for the open_window example since there was not an existing section for window-related usage examples.

Additionally, I added beginner-friendly comments across all language versions to make the example clearer and easier for new users to understand.

@anandika-nair
Copy link
Copy Markdown

Thanks for addressing all the earlier feedback! I’ve gone through the updated changes and the previously raised issues look resolved now. The example is much more consistent and beginner-friendly in its current state. The only thing I could not find is the required .png output file in the submission, which is needed as part of the usage example files. Once that’s added, I’ll be happy to approve this PR :)

@Nadiazahan
Copy link
Copy Markdown
Author

Hey @anandika-nair,
The required .png is there, ill attach a screenshot:

image

Copy link
Copy Markdown

@himanshigaba22 himanshigaba22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice , it’s clear and the output looks good 👍

Just one small thing - in the Python version, colours are still written as Color.SKY_BLUE and Color.WHITE. These should be function-style like color_sky_blue() and color_white() to match the usual convention.

Once that’s fixed, it should be good to go 👍

@Nadiazahan
Copy link
Copy Markdown
Author

Thanks for the feedback, I have now changed the py file.

Copy link
Copy Markdown

@himanshigaba22 himanshigaba22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now - all the changes have been addressed and everything is consistent 👍

Happy to approve!

Copy link
Copy Markdown

@ralphweng2023 ralphweng2023 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks clean overall, output matches the .png and the C++/C#/top-level all run fine for me. Two real things though:

  • The Python draw_text("...", color_black(), 290, 270) won't run as-is. The unsuffixed draw_text in Python is the 6-arg overload (text, clr, fnt, font_size, x, y), so a 4-arg call fails at runtime. For the (text, color, x, y) shape you want draw_text_no_font_no_size(...) — two of those calls inside the loop.
  • In the OOP .cs you're using SplashKit.ClearWindow(wind, ...), SplashKit.DrawText(...), SplashKit.RefreshWindow(wind), which is the same shape as the top-level file. The OOP version usually prefers the methods on Window itself (wind.Clear(...), wind.DrawText(...), wind.Refresh()), which is the thing that makes it distinct from top-level. The OOP value-add is small for open_window anyway, but worth tightening.

Tiny: all five files end without a trailing newline (the \ No newline at end of file marker shows on each in the diff). Easy fix on re-save.

Once the Python overload is sorted should be good to go.

@Nadiazahan
Copy link
Copy Markdown
Author

@ralphweng2023 Thanks for the detailed feedback! I’ve now updated the Python version to use the correct draw_text overload with font size parameters, updated the OOP C# example to use the wind methods (wind.Clear(), wind.DrawText(), wind.Refresh()), and re-saved all files to fix the trailing newline issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants