Giter Site home page Giter Site logo

autoscroll's Introduction

Automatically scrolling logger window for Dear PyGui that meets the following requirements.

  • Regularly update
  • Scrollable
  • Ability to automatically scroll to newest entry
  • Ability to show and hide the log with a toggle button
  • Text should be selectable
  • Automatic scrolling can be turned on and off

Automatically scrolling window

Note

The code provided in autoscroll.py runs perfectly fine by itself. However, if you just process your log file directly with textwrap.fill you will get some very strange line breaking because it doesn't preserve the existing line breaks in the file, so you need to wrap each line individually and then join them with a newline. This is illustrated in the code below.

    def update_log_display(self):
        FRAME_PADDING = 3
        log_contents = self.read_log_file("latest.log")
        lines = log_contents.splitlines()

        wrapped_lines = [textwrap.fill(line, width=128, replace_whitespace=False) for line in lines]
        wrapped_log = "\n".join(wrapped_lines)

        if wrapped_log:
            dpg.set_item_height(self.log_text, dpg.get_text_size(wrapped_log)[1] + (2 * FRAME_PADDING))
            dpg.set_value(self.log_text, wrapped_log)
        if self.log_autoscroll:
            dpg.configure_item(self.log_text, tracked=True)
        else:
            dpg.configure_item(self.log_text, tracked=False)

autoscroll's People

Contributors

dataexploreruser avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.