Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

➕ Added ToolTip, TrayTip and return types to window functions #92

Merged
merged 11 commits into from
Sep 7, 2020

Conversation

yemreak
Copy link
Contributor

@yemreak yemreak commented Jul 16, 2020

Hello, I came back ✋

➕ I added:

  • Return type to some methods to help code completion
  • ToolTip and TrayTip GUI with GUIMixin structure also gui.py file and templates

Also formatted via black with -S -l 120 args

@yemreak yemreak changed the title 👨‍💻 Added return types to window functions 👨‍💻 Added ToolTip, TrayTip and return typesto window functions Jul 17, 2020
@yemreak yemreak changed the title 👨‍💻 Added ToolTip, TrayTip and return typesto window functions ➕ Added ToolTip, TrayTip and return typesto window functions Jul 17, 2020
@yemreak yemreak changed the title ➕ Added ToolTip, TrayTip and return typesto window functions ➕ Added ToolTip, TrayTip and return types to window functions Jul 17, 2020
ahk/gui.py Outdated
Comment on lines 38 to 59
def _show_traytip(self, title: str, text: str, second=1.0, type_id=1, slient=False, large_icon=False, blocking=True):
"""Show TrayTip (Windows 10 toast notification)

https://www.autohotkey.com/docs/commands/TrayTip.htm

:param title: Title of notification
:type title: str
:param text: Content of notification
:type text: str
:param second: Wait time (s) to be disappeared, defaults to 1.0
:type second: float, optional
:param type_id: Notification type `TRAYTIP_<type>`, defaults to 1
:type type_id: int, optional
:param slient: Shows toast without sound, defaults to False
:type slient: bool, optional
:param large_icon: Shows toast with large icon, defaults to False
:type large_icon: bool, optional
"""

option = type_id + (16 if slient else 0) + (32 if large_icon else 0)
script = self.render_template("gui/traytip.ahk", title=title, text=text, second=second, option=option)
self.run_script(script, blocking=blocking)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can not show "utf-8" text like şğüı need help @spyoungtech

Copy link
Owner

@spyoungtech spyoungtech Jul 17, 2020

Choose a reason for hiding this comment

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

I believe this is a known limitation in several areas and has to do with how encoding is interpreted when sending the script via stdin, which may not be the same across systems. I have some theories on how AHK handles non-ascii input, but I haven't looked into much or confirmed; see #45

Currently, the best-supported method for non-ascii is to send along AHK-unicode sequences like {U+2F72}. Can you give that a try and see if it works?

For example şğüı might best be sent as {u+015f}{u+011f}{u+00fc}{u+0131}

If it works with the unicode escapes, I'm happy to merge in as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry but I didn't work 🤕

Copy link
Contributor Author

@yemreak yemreak Jul 18, 2020

Choose a reason for hiding this comment

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

I found some way to do this. When I send like this, it's work 🎉

  • We may decode unicode u'\U0001f618 \U0001f375' to Chr(0x1f618) Char(0x1f375) # 😘 🍵
  • Maybe this would helpfully "🚀".encode("unicode_escape") ref
  • hval = hex(ord("🚀")) # '0x1f680' we may use it for f"Chr({hval})"
ahk.show_tooltip('% Chr(0x1F680)') # Rocket 🚀

image

Char code table

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Finally, I found usable solution:

from ahk import AHK

ahk = AHK()

string = 'Rocket 🚀 man'
ahk_string = "% "
for char in string:
    hval = hex(ord(char))
    ahk_string += f"Chr({hval})"

ahk.show_tooltip(ahk_string)

image

@yemreak yemreak mentioned this pull request Jul 17, 2020
22 tasks
@yemreak
Copy link
Contributor Author

yemreak commented Jul 17, 2020

#11 #40

@spyoungtech
Copy link
Owner

spyoungtech commented Jul 17, 2020

If possible, can you split out the tooltip/traytip changes and the return types for window functions into their own separate changesets and PRs?

Thanks!

@yemreak
Copy link
Contributor Author

yemreak commented Jul 17, 2020

If possible, can you split out the tooltip/traytip changes and the return types for window functions into their own separate changesets and PRs?

Thanks!

I reverted commit

@yemreak yemreak requested a review from spyoungtech July 17, 2020 19:07
ahk/script.py Outdated Show resolved Hide resolved
ahk/autohotkey.py Show resolved Hide resolved
ahk/autohotkey.py Show resolved Hide resolved
ahk/autohotkey.py Show resolved Hide resolved
@yemreak
Copy link
Contributor Author

yemreak commented Jul 18, 2020

Could you make "Squash and merge" instead of "Merge" to show users tidy?

Comment on lines +60 to +61
encoded_title = "% " + "".join([f"Chr({hex(ord(char))})" for char in title])
encoded_text = "% " + "".join([f"Chr({hex(ord(char))})" for char in text])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unicode encoding for AHK

if id and not (1 <= int(id) <= 20):
raise ValueError("ID value must be between [1, 20]")

encoded_text = "% " + "".join([f"Chr({hex(ord(char))})" for char in text])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unicode encoding for AHK

Comment on lines +12 to +15
ahk.show_tooltip("hello")
ahk.show_tooltip("🚀 Hello unicode 🚀", second=2)
ahk.show_tooltip("⽲ hello3", x=10, y=10)
ahk.show_tooltip("hello4", second=2, x=10, y=10)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unicode tooltip test

Comment on lines +21 to +22
ahk._show_traytip("⽲ Normal 🚀", "It's me")
ahk._show_traytip("🐌 Slow 🐌", "It's you", second=2)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unicode traytip test

@yemreak
Copy link
Contributor Author

yemreak commented Jul 18, 2020

I found some way to do this. When I send like this, it's work 🎉

  • We may decode unicode u'\U0001f618 \U0001f375' to Chr(0x1f618) Char(0x1f375) # 😘 🍵
  • Maybe this would helpfully "🚀".encode("unicode_escape") ref
  • hval = hex(ord("🚀")) # '0x1f680' we may use it for f"Chr({hval})"
ahk.show_tooltip('% Chr(0x1F680)') # Rocket 🚀

image

Char code table

Finally, I found usable solution:

from ahk import AHK

ahk = AHK()

string = 'Rocket 🚀 man'
ahk_string = "% "
for char in string:
    hval = hex(ord(char))
    ahk_string += f"Chr({hval})"

ahk.show_tooltip(ahk_string)

image

Added encoded_title = "% " + "".join([f"Chr({hex(ord(char))})" for char in title]) line to necessary part of codes and tested manually 🎉

@yemreak yemreak requested a review from spyoungtech July 22, 2020 19:35
@yemreak
Copy link
Contributor Author

yemreak commented Aug 23, 2020

Hey, Could you check the PR 😕 @spyoungtech

@spyoungtech
Copy link
Owner

Hi @yedhrab apologies for the long delay. I'm not sure when I will be able to get around to this, but I'm hoping it will be some time in the next couple weeks for both the open PRs. But I haven't forgotten about this :)

@spyoungtech spyoungtech merged commit a84798f into spyoungtech:master Sep 7, 2020
@spyoungtech
Copy link
Owner

Thank you for the contribution @yedhrab I've squashed and merged to master and these changes will be included in the next release!

Cheers,
Spencer

@spyoungtech
Copy link
Owner

Released in v0.10.0

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.

2 participants