Python में फ़्लोचार्ट बनाएं

यह ट्यूटोरियल बताता है कि Python में फ़्लोचार्ट कैसे बनाया जाए। इसमें चरण-दर-चरण एल्गोरिदम और एक कार्यशील नमूना कोड दिया गया है ताकि Python में एक फ़्लोचार्ट निर्माता बनाया जा सके। इसके अलावा, आप अपनी आवश्यकताओं के अनुसार आकृतियों के प्रकार, कनेक्शन, योजना आदि बदलकर फ़्लोचार्ट निर्माण को कस्टमाइज़ कर सकते हैं।

Python में फ़्लोचार्ट बनाने के चरण

  1. Aspose.Diagram डाउनलोड करके सिस्टम वातावरण को कॉन्फ़िगर करें और फ़्लोचार्ट डायग्राम बनाएं।
  2. आवश्यक फ़्लोचार्ट की एक योजना निर्धारित करें।
  3. Diagram क्लास का एक इंस्टांस बनाएं और मास्टर स्टेंसिल से विभिन्न आकृतियाँ जोड़ें।
  4. लक्ष्य लेआउट निर्दिष्ट करें और save मेथड के साथ आउटपुट फ़्लोचार्ट प्रस्तुत करें।

ये चरण Python में फ़्लोचार्ट जनरेटर बनाने के लिए आवश्यक कार्यप्रवाह को स्पष्ट करते हैं। पहले चरण में, आवश्यक मानकों को निर्दिष्ट करने के लिए एक योजना बनाएं। फिर, मास्टर स्टेंसिल का उपयोग करके विभिन्न आकृतियों को जोड़ें और अंत में तैयार फ़्लोचार्ट को निर्यात करें।

Python में फ़्लोचार्ट जनरेटर बनाने का कोड

import aspose.diagram
from aspose.diagram import *
path = "C://"
import aspose.diagram
from aspose.diagram import *
def createFlowChart():
# schema for the diagram to be created
diagram_object = Input(
input_rectangles=[
InputRectangle("A", "Manager"),
InputRectangle("B", "Team Leader"),
InputRectangle("C", "Team Member"),
InputRectangle("D", "Team Member"),
InputRectangle("E", "Team Member")
],
input_connectors=[
InputConnector("A", "B"),
InputConnector("B", "C"),
InputConnector("B", "D"),
InputConnector("B", "E")
]
)
diagram = Diagram(path + "BasicShapes.vss")
page = diagram.pages[0]
shape_names = {}
# Adding shapes and connectors from the schema
for rectangle in diagram_object.InputRectangles:
shape = Shape()
shape_id = diagram.add_shape(shape, "Rectangle", 0)
shape_names[rectangle.Name] = shape_id
shape = page.shapes.get_shape(shape_id)
shape.text.value.add(Txt(rectangle.Text))
for connector in diagram_object.InputConnectors:
connector_id = diagram.add_shape(Shape(), "Dynamic connector", 0)
page.connect_shapes_via_connector(
shape_names[connector.OriginShapeName],
aspose.diagram.manipulation.ConnectionPointPlace.RIGHT,
shape_names[connector.DestinationShapeName],
aspose.diagram.manipulation.ConnectionPointPlace.LEFT,
connector_id
)
layout_options = aspose.diagram.autolayout.LayoutOptions()
layout_options.layout_style = aspose.diagram.autolayout.LayoutStyle.FLOW_CHART
layout_options.direction = aspose.diagram.autolayout.LayoutDirection.LEFT_TO_RIGHT
layout_options.space_shapes = 5.0
layout_options.enlarge_page = True
diagram.layout(layout_options)
page.page_sheet.print_props.print_page_orientation.value = PrintPageOrientationValue.LANDSCAPE
save_options = aspose.diagram.saving.DiagramSaveOptions()
save_options.save_format = SaveFileFormat.VSDX
save_options.auto_fit_page_to_drawing_content = True
diagram.save(path + "flowchart_output.vsdx", save_options)
class Input:
def __init__(self, input_rectangles=None, input_connectors=None):
self.InputRectangles = input_rectangles if input_rectangles else []
self.InputConnectors = input_connectors if input_connectors else []
class InputRectangle:
def __init__(self, name, text):
self.Name = name
self.Text = text
class InputConnector:
def __init__(self, origin_shape_name, destination_shape_name):
self.OriginShapeName = origin_shape_name
self.DestinationShapeName = destination_shape_name
createFlowChart()

ऊपर दिया गया नमूना कोड Python में फ़्लोचार्ट ड्रॉ करने का एक त्वरित प्रदर्शन है। यह मुख्य रूप से Diagram क्लास का उपयोग करता है ताकि विभिन्न आकृतियों को लोड किया जा सके, फ़्लोचार्ट लेआउट सेट किया जा सके और तैयार फ़्लोचार्ट प्रस्तुत किया जा सके। इसके अलावा, आप डिज़ाइन को अपनी आवश्यकताओं के अनुसार सुधारने के लिए इसे विभिन्न अभिविन्यासों जैसे कि बाएं से दाएं, दाएं से बाएं, ऊपर से नीचे आदि में समायोजित कर सकते हैं।

यह लेख Python में फ़्लोचार्ट बिल्डर डिज़ाइन करने की जानकारी प्रदान करता है। हालांकि, यदि आप एक संगठनात्मक चार्ट (ORG चार्ट) बनाना चाहते हैं, तो Python में ORG चार्ट बनाएं लेख पढ़ें।

 हिन्दी